Remove custom types

This commit is contained in:
Sam
2020-02-29 10:12:15 -05:00
parent c031c36a00
commit ca2a1fdf25
2 changed files with 13 additions and 36 deletions

24
chat.go
View File

@ -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{

View File

@ -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
}