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
|
|
|
|
2021-08-03 19:27:15 +00:00
|
|
|
func (h PublisherSignalHandler) Stats(stats types.StatsSummary) {
|
|
|
|
signal.SendStats(stats)
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2021-10-11 15:39:52 +00:00
|
|
|
// BackupPerformed passes information that a backup was performed
|
|
|
|
func (m MessengerSignalsHandler) BackupPerformed(lastBackup uint64) {
|
|
|
|
signal.SendBackupPerformed(lastBackup)
|
|
|
|
}
|
|
|
|
|
2021-04-19 12:09:46 +00:00
|
|
|
// 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)
|
|
|
|
}
|
2021-09-28 18:41:35 +00:00
|
|
|
|
2021-11-09 21:16:19 +00:00
|
|
|
func (m *MessengerSignalsHandler) HistoryRequestStarted(requestID string, numBatches int) {
|
|
|
|
signal.SendHistoricMessagesRequestStarted(requestID, numBatches)
|
2021-09-28 18:41:35 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 21:16:19 +00:00
|
|
|
func (m *MessengerSignalsHandler) HistoryRequestBatchProcessed(requestID string, batchIndex int, numBatches int) {
|
|
|
|
signal.SendHistoricMessagesRequestBatchProcessed(requestID, batchIndex, numBatches)
|
2021-09-28 18:41:35 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 21:16:19 +00:00
|
|
|
func (m *MessengerSignalsHandler) HistoryRequestFailed(requestID string, err error) {
|
|
|
|
signal.SendHistoricMessagesRequestFailed(requestID, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) HistoryRequestCompleted(requestID string) {
|
|
|
|
signal.SendHistoricMessagesRequestCompleted(requestID)
|
2021-09-28 18:41:35 +00:00
|
|
|
}
|
2022-03-21 14:18:36 +00:00
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) HistoryArchivesProtocolEnabled() {
|
|
|
|
signal.SendHistoryArchivesProtocolEnabled()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) HistoryArchivesProtocolDisabled() {
|
|
|
|
signal.SendHistoryArchivesProtocolDisabled()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) CreatingHistoryArchives(communityID string) {
|
|
|
|
signal.SendCreatingHistoryArchives(communityID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) NoHistoryArchivesCreated(communityID string, from int, to int) {
|
|
|
|
signal.SendNoHistoryArchivesCreated(communityID, from, to)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) HistoryArchivesCreated(communityID string, from int, to int) {
|
|
|
|
signal.SendHistoryArchivesCreated(communityID, from, to)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) HistoryArchivesSeeding(communityID string) {
|
|
|
|
signal.SendHistoryArchivesSeeding(communityID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) HistoryArchivesUnseeded(communityID string) {
|
|
|
|
signal.SendHistoryArchivesUnseeded(communityID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) HistoryArchiveDownloaded(communityID string, from int, to int) {
|
|
|
|
signal.SendHistoryArchiveDownloaded(communityID, from, to)
|
|
|
|
}
|
2022-08-02 23:08:01 +00:00
|
|
|
|
|
|
|
func (m *MessengerSignalsHandler) StatusUpdatesTimedOut(statusUpdates *[]protocol.UserStatus) {
|
|
|
|
signal.SendStatusUpdatesTimedOut(statusUpdates)
|
|
|
|
}
|