2020-01-20 20:56:06 +00:00
|
|
|
package ext
|
2018-04-11 15:41:51 +00:00
|
|
|
|
|
|
|
import (
|
2019-11-23 17:57:05 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
Move to protobuf for Message type (#1706)
* Use a single Message type `v1/message.go` and `message.go` are the same now, and they embed `protobuf.ChatMessage`
* Use `SendChatMessage` for sending chat messages, this is basically the old `Send` but a bit more flexible so we can send different message types (stickers,commands), and not just text.
* Remove dedup from services/shhext. Because now we process in status-protocol, dedup makes less sense, as those messages are going to be processed anyway, so removing for now, we can re-evaluate if bringing it to status-go or not.
* Change the various retrieveX method to a single one:
`RetrieveAll` will be processing those messages that it can process (Currently only `Message`), and return the rest in `RawMessages` (still transit). The format for the response is:
`Chats`: -> The chats updated by receiving the message
`Messages`: -> The messages retrieved (already matched to a chat)
`Contacts`: -> The contacts updated by the messages
`RawMessages` -> Anything else that can't be parsed, eventually as we move everything to status-protocol-go this will go away.
2019-12-05 16:25:34 +00:00
|
|
|
"github.com/status-im/status-go/protocol"
|
2021-04-19 12:09:46 +00:00
|
|
|
"github.com/status-im/status-go/protocol/communities"
|
2018-05-03 07:35:58 +00:00
|
|
|
"github.com/status-im/status-go/signal"
|
2018-04-11 15:41:51 +00:00
|
|
|
)
|
|
|
|
|
2018-04-13 05:52:22 +00:00
|
|
|
// EnvelopeSignalHandler sends signals when envelope is sent or expired.
|
|
|
|
type EnvelopeSignalHandler struct{}
|
|
|
|
|
|
|
|
// EnvelopeSent triggered when envelope delivered atleast to 1 peer.
|
2019-08-09 07:03:10 +00:00
|
|
|
func (h EnvelopeSignalHandler) EnvelopeSent(identifiers [][]byte) {
|
|
|
|
signal.SendEnvelopeSent(identifiers)
|
2018-04-13 05:52:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// EnvelopeExpired triggered when envelope is expired but wasn't delivered to any peer.
|
2019-08-09 07:03:10 +00:00
|
|
|
func (h EnvelopeSignalHandler) EnvelopeExpired(identifiers [][]byte, err error) {
|
|
|
|
signal.SendEnvelopeExpired(identifiers, err)
|
2018-04-11 15:41:51 +00:00
|
|
|
}
|
2018-06-15 15:12:31 +00:00
|
|
|
|
2018-07-02 07:38:10 +00:00
|
|
|
// MailServerRequestCompleted triggered when the mailserver sends a message to notify that the request has been completed
|
2019-11-23 17:57:05 +00:00
|
|
|
func (h EnvelopeSignalHandler) MailServerRequestCompleted(requestID types.Hash, lastEnvelopeHash types.Hash, cursor []byte, err error) {
|
2018-10-18 10:25:00 +00:00
|
|
|
signal.SendMailServerRequestCompleted(requestID, lastEnvelopeHash, cursor, err)
|
2018-06-15 15:12:31 +00:00
|
|
|
}
|
|
|
|
|
2018-07-02 07:38:10 +00:00
|
|
|
// MailServerRequestExpired triggered when the mailserver request expires
|
2019-11-23 17:57:05 +00:00
|
|
|
func (h EnvelopeSignalHandler) MailServerRequestExpired(hash types.Hash) {
|
2018-06-15 15:12:31 +00:00
|
|
|
signal.SendMailServerRequestExpired(hash)
|
|
|
|
}
|
2019-07-01 09:39:51 +00:00
|
|
|
|
|
|
|
// PublisherSignalHandler sends signals on protocol events
|
|
|
|
type PublisherSignalHandler struct{}
|
|
|
|
|
|
|
|
func (h PublisherSignalHandler) DecryptMessageFailed(pubKey string) {
|
|
|
|
signal.SendDecryptMessageFailed(pubKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h PublisherSignalHandler) BundleAdded(identity string, installationID string) {
|
|
|
|
signal.SendBundleAdded(identity, installationID)
|
|
|
|
}
|
|
|
|
|
Move to protobuf for Message type (#1706)
* Use a single Message type `v1/message.go` and `message.go` are the same now, and they embed `protobuf.ChatMessage`
* Use `SendChatMessage` for sending chat messages, this is basically the old `Send` but a bit more flexible so we can send different message types (stickers,commands), and not just text.
* Remove dedup from services/shhext. Because now we process in status-protocol, dedup makes less sense, as those messages are going to be processed anyway, so removing for now, we can re-evaluate if bringing it to status-go or not.
* Change the various retrieveX method to a single one:
`RetrieveAll` will be processing those messages that it can process (Currently only `Message`), and return the rest in `RawMessages` (still transit). The format for the response is:
`Chats`: -> The chats updated by receiving the message
`Messages`: -> The messages retrieved (already matched to a chat)
`Contacts`: -> The contacts updated by the messages
`RawMessages` -> Anything else that can't be parsed, eventually as we move everything to status-protocol-go this will go away.
2019-12-05 16:25:34 +00:00
|
|
|
func (h PublisherSignalHandler) NewMessages(response *protocol.MessengerResponse) {
|
|
|
|
signal.SendNewMessages(response)
|
2019-07-01 10:00:46 +00:00
|
|
|
}
|
2021-04-19 12:09:46 +00:00
|
|
|
|
|
|
|
// MessengerSignalHandler sends signals on messenger events
|
|
|
|
type MessengerSignalsHandler struct{}
|
|
|
|
|
|
|
|
// MessageDelivered passes information that message was delivered
|
|
|
|
func (m MessengerSignalsHandler) MessageDelivered(chatID string, messageID string) {
|
|
|
|
signal.SendMessageDelivered(chatID, messageID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MessageDelivered passes info about community that was requested before
|
|
|
|
func (m MessengerSignalsHandler) CommunityInfoFound(community *communities.Community) {
|
|
|
|
signal.SendCommunityInfoFound(community)
|
|
|
|
}
|
2021-03-25 15:15:22 +00:00
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) MessengerResponse(response *protocol.MessengerResponse) {
|
|
|
|
PublisherSignalHandler{}.NewMessages(response)
|
|
|
|
}
|