From ca2a1fdf2596e61e2166a0d999db28cb386e8ffa Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 29 Feb 2020 10:12:15 -0500 Subject: [PATCH] Remove custom types --- chat.go | 24 +++++++----------------- types.go | 25 ++++++------------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/chat.go b/chat.go index f88835b..a636f92 100644 --- a/chat.go +++ b/chat.go @@ -11,6 +11,7 @@ import ( "time" "samhofi.us/x/keybase/types/chat1" + "samhofi.us/x/keybase/types/stellar1" ) // Returns a string representation of a message id suitable for use in a @@ -86,14 +87,7 @@ func getNewMessages(k *Keybase, subs *SubscriptionChannels, execOptions []string break } if notification.Msg != nil { - subscriptionMessage := SubscriptionMessage{ - Message: *notification.Msg, - Conversation: chat1.ConvSummary{ - Id: notification.Msg.ConvID, - Channel: notification.Msg.Channel, - }, - } - subs.chat <- subscriptionMessage + subs.chat <- *notification.Msg } case "chat_conv": var notification chat1.ConvNotification @@ -102,10 +96,7 @@ func getNewMessages(k *Keybase, subs *SubscriptionChannels, execOptions []string break } if notification.Conv != nil { - subscriptionConv := SubscriptionConversation{ - Conversation: *notification.Conv, - } - subs.conversation <- subscriptionConv + subs.conversation <- *notification.Conv } case "wallet": var holder paymentHolder @@ -113,8 +104,7 @@ func getNewMessages(k *Keybase, subs *SubscriptionChannels, execOptions []string subs.error <- err break } - subscriptionPayment := SubscriptionWalletEvent(holder) - subs.wallet <- subscriptionPayment + subs.wallet <- holder.Payment default: continue } @@ -159,9 +149,9 @@ func (k *Keybase) Run(handlers Handlers, options ...RunOptions) { } } - chatCh := make(chan SubscriptionMessage, channelCapacity) - convCh := make(chan SubscriptionConversation, channelCapacity) - walletCh := make(chan SubscriptionWalletEvent, channelCapacity) + chatCh := make(chan chat1.MsgSummary, channelCapacity) + convCh := make(chan chat1.ConvSummary, channelCapacity) + walletCh := make(chan stellar1.PaymentDetailsLocal, channelCapacity) errorCh := make(chan error, channelCapacity) subs := &SubscriptionChannels{ diff --git a/types.go b/types.go index b954afe..b8c4ba6 100644 --- a/types.go +++ b/types.go @@ -26,34 +26,21 @@ type subscriptionType struct { Type string `json:"type"` } -type SubscriptionMessage struct { - Message chat1.MsgSummary - Conversation chat1.ConvSummary -} - -type SubscriptionConversation struct { - Conversation chat1.ConvSummary -} - -type SubscriptionWalletEvent struct { - Payment stellar1.PaymentDetailsLocal -} - type paymentHolder struct { Payment stellar1.PaymentDetailsLocal `json:"notification"` } type Handlers struct { - ChatHandler *func(SubscriptionMessage) - ConversationHandler *func(SubscriptionConversation) - WalletHandler *func(SubscriptionWalletEvent) + ChatHandler *func(chat1.MsgSummary) + ConversationHandler *func(chat1.ConvSummary) + WalletHandler *func(stellar1.PaymentDetailsLocal) ErrorHandler *func(error) } type SubscriptionChannels struct { - chat chan SubscriptionMessage - conversation chan SubscriptionConversation - wallet chan SubscriptionWalletEvent + chat chan chat1.MsgSummary + conversation chan chat1.ConvSummary + wallet chan stellar1.PaymentDetailsLocal error chan error }