2021-02-23 15:47:45 +00:00
|
|
|
package signal
|
|
|
|
|
|
|
|
const (
|
2022-07-06 11:44:40 +00:00
|
|
|
// EventMediaServerStarted triggers when the media server successfully binds a new port
|
|
|
|
EventMediaServerStarted = "mediaserver.started"
|
|
|
|
|
2021-02-23 15:47:45 +00:00
|
|
|
// EventMesssageDelivered triggered when we got acknowledge from datasync level, that means peer got message
|
|
|
|
EventMesssageDelivered = "message.delivered"
|
2021-04-19 12:09:46 +00:00
|
|
|
|
2022-10-19 10:01:04 +00:00
|
|
|
// EventCommunityInfoFound triggered when user requested info about some community and messenger successfully
|
2021-04-19 12:09:46 +00:00
|
|
|
// retrieved it from mailserver
|
|
|
|
EventCommunityInfoFound = "community.found"
|
2022-08-02 23:08:01 +00:00
|
|
|
|
2022-10-19 10:01:04 +00:00
|
|
|
// EventStatusUpdatesTimedOut Event Automatic Status Updates Timed out
|
2022-08-02 23:08:01 +00:00
|
|
|
EventStatusUpdatesTimedOut = "status.updates.timedout"
|
2021-02-23 15:47:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MessageDeliveredSignal specifies chat and message that was delivered
|
|
|
|
type MessageDeliveredSignal struct {
|
|
|
|
ChatID string `json:"chatID"`
|
|
|
|
MessageID string `json:"messageID"`
|
|
|
|
}
|
|
|
|
|
2022-07-06 11:44:40 +00:00
|
|
|
// MediaServerStarted specifies chat and message that was delivered
|
|
|
|
type MediaServerStarted struct {
|
2022-08-07 07:35:54 +00:00
|
|
|
Port int `json:"port"`
|
2022-07-06 11:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MessageDeliveredSignal specifies chat and message that was delivered
|
2021-04-19 12:09:46 +00:00
|
|
|
type CommunityInfoFoundSignal struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Description string `json:"description"`
|
|
|
|
MembersCount int `json:"membersCount"`
|
|
|
|
Verified bool `json:"verified"`
|
|
|
|
}
|
|
|
|
|
2021-02-23 15:47:45 +00:00
|
|
|
// SendMessageDelivered notifies about delivered message
|
|
|
|
func SendMessageDelivered(chatID string, messageID string) {
|
|
|
|
send(EventMesssageDelivered, MessageDeliveredSignal{ChatID: chatID, MessageID: messageID})
|
|
|
|
}
|
2021-04-19 12:09:46 +00:00
|
|
|
|
2022-07-06 11:44:40 +00:00
|
|
|
// SendMediaServerStarted notifies about restarts of the media server
|
|
|
|
func SendMediaServerStarted(port int) {
|
|
|
|
send(EventMediaServerStarted, MediaServerStarted{Port: port})
|
|
|
|
}
|
|
|
|
|
2021-04-19 12:09:46 +00:00
|
|
|
// SendMessageDelivered notifies about delivered message
|
2021-07-21 10:08:08 +00:00
|
|
|
func SendCommunityInfoFound(community interface{}) {
|
2021-04-19 12:09:46 +00:00
|
|
|
send(EventCommunityInfoFound, community)
|
|
|
|
}
|
2022-08-02 23:08:01 +00:00
|
|
|
|
|
|
|
func SendStatusUpdatesTimedOut(statusUpdates interface{}) {
|
|
|
|
send(EventStatusUpdatesTimedOut, statusUpdates)
|
|
|
|
}
|