gmessages/libgm/messages.go

49 lines
1.3 KiB
Go
Raw Normal View History

package libgm
import (
"fmt"
"go.mau.fi/mautrix-gmessages/libgm/binary"
)
func (c *Client) SendReaction(payload *binary.SendReactionPayload) (*binary.SendReactionResponse, error) {
actionType := binary.ActionType_SEND_REACTION
2023-07-15 22:45:57 +00:00
response, err := c.sessionHandler.sendMessage(actionType, payload)
if err != nil {
return nil, err
}
res, ok := response.Data.Decrypted.(*binary.SendReactionResponse)
if !ok {
2023-07-15 21:16:36 +00:00
return nil, fmt.Errorf("unexpected response type %T, expected *binary.SendReactionResponse", response.Data.Decrypted)
}
return res, nil
}
func (c *Client) DeleteMessage(messageID string) (*binary.DeleteMessageResponse, error) {
payload := &binary.DeleteMessagePayload{MessageID: messageID}
actionType := binary.ActionType_DELETE_MESSAGE
2023-07-15 22:45:57 +00:00
response, err := c.sessionHandler.sendMessage(actionType, payload)
if err != nil {
return nil, err
}
res, ok := response.Data.Decrypted.(*binary.DeleteMessageResponse)
if !ok {
2023-07-15 21:16:36 +00:00
return nil, fmt.Errorf("unexpected response type %T, expected *binary.DeleteMessagesResponse", response.Data.Decrypted)
}
return res, nil
}
2023-07-15 11:38:24 +00:00
func (c *Client) MarkRead(conversationID, messageID string) error {
2023-07-15 11:38:24 +00:00
payload := &binary.MessageReadPayload{ConversationID: conversationID, MessageID: messageID}
actionType := binary.ActionType_MESSAGE_READ
2023-07-15 22:45:57 +00:00
_, err := c.sessionHandler.sendMessage(actionType, payload)
return err
2023-07-15 11:38:24 +00:00
}