diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2024-01-27 05:02:47 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2024-01-27 05:02:47 +0300 |
commit | e37c428c6764eff8e7b5ea286b1c7a0ba52be11a (patch) | |
tree | ff1dd7c431499e93dff99669b8df90805ea59118 /telegram/utils.go | |
parent | b9b6ba14a442f3c4394c535461bd6b1d03a7ef7b (diff) |
XEP-0333 read markers for outgoing messages
Diffstat (limited to 'telegram/utils.go')
-rw-r--r-- | telegram/utils.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/telegram/utils.go b/telegram/utils.go index 3f15488..6aab03a 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -1472,6 +1472,27 @@ func (c *Client) UpdateChatNicknames() { } } +// AddToEditOutbox temporarily store the resource from which a replace message with given ID was sent +func (c *Client) AddToEditOutbox(xmppId, resource string) { + c.locks.editOutboxLock.Lock() + defer c.locks.editOutboxLock.Unlock() + + c.editOutbox[xmppId] = resource +} + +func (c *Client) popFromEditOutbox(xmppId string) string { + c.locks.editOutboxLock.Lock() + defer c.locks.editOutboxLock.Unlock() + + resource, ok := c.editOutbox[xmppId] + if ok { + delete(c.editOutbox, xmppId) + } else { + log.Warnf("No %v xmppId in edit outbox", xmppId) + } + return resource +} + // AddToOutbox remembers the resource from which a message with given ID was sent func (c *Client) AddToOutbox(xmppId, resource string) { c.locks.outboxLock.Lock() @@ -1480,14 +1501,12 @@ func (c *Client) AddToOutbox(xmppId, resource string) { c.outbox[xmppId] = resource } -func (c *Client) popFromOutbox(xmppId string) string { +func (c *Client) getFromOutbox(xmppId string) string { c.locks.outboxLock.Lock() defer c.locks.outboxLock.Unlock() resource, ok := c.outbox[xmppId] - if ok { - delete(c.outbox, xmppId) - } else { + if !ok { log.Warnf("No %v xmppId in outbox", xmppId) } return resource |