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

25
types.go

@ -26,34 +26,21 @@ type subscriptionType struct { @@ -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
}

Loading…
Cancel
Save