2020-01-20 21:56:06 +01:00
|
|
|
package ext
|
2018-04-11 18:41:51 +03:00
|
|
|
|
|
|
|
import (
|
2019-11-23 18:57:05 +01: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 17:25:34 +01:00
|
|
|
"github.com/status-im/status-go/protocol"
|
2018-05-03 09:35:58 +02:00
|
|
|
"github.com/status-im/status-go/signal"
|
2018-04-11 18:41:51 +03:00
|
|
|
)
|
|
|
|
|
2018-04-13 08:52:22 +03: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 09:03:10 +02:00
|
|
|
func (h EnvelopeSignalHandler) EnvelopeSent(identifiers [][]byte) {
|
|
|
|
signal.SendEnvelopeSent(identifiers)
|
2018-04-13 08:52:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// EnvelopeExpired triggered when envelope is expired but wasn't delivered to any peer.
|
2019-08-09 09:03:10 +02:00
|
|
|
func (h EnvelopeSignalHandler) EnvelopeExpired(identifiers [][]byte, err error) {
|
|
|
|
signal.SendEnvelopeExpired(identifiers, err)
|
2018-04-11 18:41:51 +03:00
|
|
|
}
|
2018-06-15 17:12:31 +02:00
|
|
|
|
2018-07-02 09:38:10 +02:00
|
|
|
// MailServerRequestCompleted triggered when the mailserver sends a message to notify that the request has been completed
|
2019-11-23 18:57:05 +01:00
|
|
|
func (h EnvelopeSignalHandler) MailServerRequestCompleted(requestID types.Hash, lastEnvelopeHash types.Hash, cursor []byte, err error) {
|
2018-10-18 12:25:00 +02:00
|
|
|
signal.SendMailServerRequestCompleted(requestID, lastEnvelopeHash, cursor, err)
|
2018-06-15 17:12:31 +02:00
|
|
|
}
|
|
|
|
|
2018-07-02 09:38:10 +02:00
|
|
|
// MailServerRequestExpired triggered when the mailserver request expires
|
2019-11-23 18:57:05 +01:00
|
|
|
func (h EnvelopeSignalHandler) MailServerRequestExpired(hash types.Hash) {
|
2018-06-15 17:12:31 +02:00
|
|
|
signal.SendMailServerRequestExpired(hash)
|
|
|
|
}
|
2019-07-01 11:39:51 +02: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)
|
|
|
|
}
|
|
|
|
|
2020-01-20 21:56:06 +01:00
|
|
|
func (h PublisherSignalHandler) FilterAdded(filters []*signal.Filter) {
|
|
|
|
// TODO(waku): change the name of the filter to generic one.
|
2019-07-01 11:39:51 +02:00
|
|
|
signal.SendWhisperFilterAdded(filters)
|
|
|
|
}
|
2019-07-01 12:00:46 +02:00
|
|
|
|
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 17:25:34 +01:00
|
|
|
func (h PublisherSignalHandler) NewMessages(response *protocol.MessengerResponse) {
|
|
|
|
signal.SendNewMessages(response)
|
2019-07-01 12:00:46 +02:00
|
|
|
}
|