Browse Source

Remove custom types

main
Sam 4 years ago
parent
commit
ca2a1fdf25
  1. 24
      chat.go
  2. 25
      types.go

24
chat.go

@ -11,6 +11,7 @@ import (
"time" "time"
"samhofi.us/x/keybase/types/chat1" "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 // 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 break
} }
if notification.Msg != nil { if notification.Msg != nil {
subscriptionMessage := SubscriptionMessage{ subs.chat <- *notification.Msg
Message: *notification.Msg,
Conversation: chat1.ConvSummary{
Id: notification.Msg.ConvID,
Channel: notification.Msg.Channel,
},
}
subs.chat <- subscriptionMessage
} }
case "chat_conv": case "chat_conv":
var notification chat1.ConvNotification var notification chat1.ConvNotification
@ -102,10 +96,7 @@ func getNewMessages(k *Keybase, subs *SubscriptionChannels, execOptions []string
break break
} }
if notification.Conv != nil { if notification.Conv != nil {
subscriptionConv := SubscriptionConversation{ subs.conversation <- *notification.Conv
Conversation: *notification.Conv,
}
subs.conversation <- subscriptionConv
} }
case "wallet": case "wallet":
var holder paymentHolder var holder paymentHolder
@ -113,8 +104,7 @@ func getNewMessages(k *Keybase, subs *SubscriptionChannels, execOptions []string
subs.error <- err subs.error <- err
break break
} }
subscriptionPayment := SubscriptionWalletEvent(holder) subs.wallet <- holder.Payment
subs.wallet <- subscriptionPayment
default: default:
continue continue
} }
@ -159,9 +149,9 @@ func (k *Keybase) Run(handlers Handlers, options ...RunOptions) {
} }
} }
chatCh := make(chan SubscriptionMessage, channelCapacity) chatCh := make(chan chat1.MsgSummary, channelCapacity)
convCh := make(chan SubscriptionConversation, channelCapacity) convCh := make(chan chat1.ConvSummary, channelCapacity)
walletCh := make(chan SubscriptionWalletEvent, channelCapacity) walletCh := make(chan stellar1.PaymentDetailsLocal, channelCapacity)
errorCh := make(chan error, channelCapacity) errorCh := make(chan error, channelCapacity)
subs := &SubscriptionChannels{ subs := &SubscriptionChannels{

25
types.go

@ -26,34 +26,21 @@ type subscriptionType struct {
Type string `json:"type"` 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 { type paymentHolder struct {
Payment stellar1.PaymentDetailsLocal `json:"notification"` Payment stellar1.PaymentDetailsLocal `json:"notification"`
} }
type Handlers struct { type Handlers struct {
ChatHandler *func(SubscriptionMessage) ChatHandler *func(chat1.MsgSummary)
ConversationHandler *func(SubscriptionConversation) ConversationHandler *func(chat1.ConvSummary)
WalletHandler *func(SubscriptionWalletEvent) WalletHandler *func(stellar1.PaymentDetailsLocal)
ErrorHandler *func(error) ErrorHandler *func(error)
} }
type SubscriptionChannels struct { type SubscriptionChannels struct {
chat chan SubscriptionMessage chat chan chat1.MsgSummary
conversation chan SubscriptionConversation conversation chan chat1.ConvSummary
wallet chan SubscriptionWalletEvent wallet chan stellar1.PaymentDetailsLocal
error chan error error chan error
} }

Loading…
Cancel
Save