2023-06-30 11:05:33 +00:00
|
|
|
package libgm
|
2023-06-30 09:54:08 +00:00
|
|
|
|
2023-07-09 11:16:52 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-07-17 13:51:31 +00:00
|
|
|
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
|
2023-07-09 11:16:52 +00:00
|
|
|
)
|
2023-06-30 09:54:08 +00:00
|
|
|
|
2023-07-15 21:26:22 +00:00
|
|
|
func (c *Client) SetActiveSession() error {
|
2023-07-15 22:45:57 +00:00
|
|
|
c.sessionHandler.ResetSessionID()
|
2023-07-17 13:51:31 +00:00
|
|
|
actionType := gmproto.ActionType_GET_UPDATES
|
2023-07-15 22:45:57 +00:00
|
|
|
return c.sessionHandler.sendMessageNoResponse(actionType, nil)
|
2023-06-30 09:54:08 +00:00
|
|
|
}
|
|
|
|
|
2023-07-17 13:51:31 +00:00
|
|
|
func (c *Client) IsBugleDefault() (*gmproto.IsBugleDefaultResponse, error) {
|
2023-07-15 22:45:57 +00:00
|
|
|
c.sessionHandler.ResetSessionID()
|
2023-06-30 09:54:08 +00:00
|
|
|
|
2023-07-17 13:51:31 +00:00
|
|
|
actionType := gmproto.ActionType_IS_BUGLE_DEFAULT
|
2023-06-30 09:54:08 +00:00
|
|
|
|
2023-07-15 22:45:57 +00:00
|
|
|
response, err := c.sessionHandler.sendMessage(actionType, nil)
|
2023-06-30 09:54:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-07-17 23:01:06 +00:00
|
|
|
res, ok := response.DecryptedMessage.(*gmproto.IsBugleDefaultResponse)
|
2023-07-09 11:16:52 +00:00
|
|
|
if !ok {
|
2023-07-17 23:01:06 +00:00
|
|
|
return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.IsBugleDefaultResponse", response.DecryptedMessage)
|
2023-07-09 11:16:52 +00:00
|
|
|
}
|
2023-06-30 09:54:08 +00:00
|
|
|
|
2023-07-09 11:16:52 +00:00
|
|
|
return res, nil
|
2023-06-30 09:54:08 +00:00
|
|
|
}
|
|
|
|
|
2023-07-15 21:26:22 +00:00
|
|
|
func (c *Client) NotifyDittoActivity() error {
|
2023-07-17 13:51:31 +00:00
|
|
|
payload := &gmproto.NotifyDittoActivityPayload{Success: true}
|
|
|
|
actionType := gmproto.ActionType_NOTIFY_DITTO_ACTIVITY
|
2023-06-30 09:54:08 +00:00
|
|
|
|
2023-07-15 22:45:57 +00:00
|
|
|
_, err := c.sessionHandler.sendMessage(actionType, payload)
|
|
|
|
return err
|
2023-06-30 09:54:08 +00:00
|
|
|
}
|