From 4d6233d94b7ed4d654201c5b25bb9fbf153885ea Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 17 Jul 2023 16:51:31 +0300 Subject: [PATCH] Rename binary package to gmproto --- database/message.go | 4 +- gmtest/main.go | 6 +- libgm/client.go | 24 ++-- libgm/conversation_builder.go | 28 ++--- libgm/conversations.go | 96 ++++++++-------- libgm/event_handler.go | 8 +- libgm/events/qr.go | 4 +- libgm/events/ready.go | 6 +- .../{binary => gmproto}/authentication.pb.go | 2 +- .../{binary => gmproto}/authentication.pb.raw | Bin 1362 -> 1363 bytes .../{binary => gmproto}/authentication.proto | 2 +- libgm/{binary => gmproto}/client.pb.go | 2 +- libgm/{binary => gmproto}/client.pb.raw | Bin 1148 -> 1149 bytes libgm/{binary => gmproto}/client.proto | 2 +- libgm/{binary => gmproto}/conversations.pb.go | 2 +- .../{binary => gmproto}/conversations.pb.raw | Bin 10937 -> 10938 bytes libgm/{binary => gmproto}/conversations.proto | 2 +- libgm/{binary => gmproto}/emojitype.go | 2 +- libgm/{binary => gmproto}/events.pb.go | 2 +- libgm/{binary => gmproto}/events.pb.raw | Bin 1949 -> 1950 bytes libgm/{binary => gmproto}/events.proto | 2 +- libgm/{binary => gmproto}/media.pb.go | 2 +- libgm/{binary => gmproto}/media.pb.raw | Bin 362 -> 363 bytes libgm/{binary => gmproto}/media.proto | 2 +- libgm/{binary => gmproto}/messages.pb.go | 2 +- libgm/{binary => gmproto}/messages.pb.raw | Bin 4633 -> 4634 bytes libgm/{binary => gmproto}/messages.proto | 2 +- libgm/{binary => gmproto}/reactions.pb.go | 2 +- libgm/{binary => gmproto}/reactions.pb.raw | Bin 855 -> 856 bytes libgm/{binary => gmproto}/reactions.proto | 2 +- libgm/{binary => gmproto}/responses.pb.go | 2 +- libgm/{binary => gmproto}/responses.pb.raw | Bin 2297 -> 2298 bytes libgm/{binary => gmproto}/responses.proto | 2 +- libgm/{binary => gmproto}/settings.pb.go | 2 +- libgm/{binary => gmproto}/settings.pb.raw | Bin 1617 -> 1618 bytes libgm/{binary => gmproto}/settings.proto | 2 +- libgm/messages.go | 24 ++-- libgm/pair.go | 38 +++---- libgm/pairing_handler.go | 10 +- libgm/payload/sendMessage.go | 30 ++--- libgm/pblite/internal.go | 58 +++++----- libgm/routes/conversations.go | 48 ++++---- libgm/routes/mapped.go | 42 +++---- libgm/routes/messages.go | 40 +++---- libgm/routes/session.go | 48 ++++---- libgm/rpc.go | 12 +- libgm/session.go | 16 +-- libgm/session_handler.go | 20 ++-- libgm/updates_handler.go | 22 ++-- libgm/upload.go | 106 +++++++++--------- libgm/util/config.go | 8 +- libgm/util/func.go | 6 +- main.go | 6 +- messagetracking.go | 6 +- portal.go | 86 +++++++------- provisioning.go | 10 +- puppet.go | 4 +- user.go | 34 +++--- 58 files changed, 444 insertions(+), 444 deletions(-) rename libgm/{binary => gmproto}/authentication.pb.go (99%) rename libgm/{binary => gmproto}/authentication.pb.raw (94%) rename libgm/{binary => gmproto}/authentication.proto (97%) rename libgm/{binary => gmproto}/client.pb.go (99%) rename libgm/{binary => gmproto}/client.pb.raw (97%) rename libgm/{binary => gmproto}/client.proto (97%) rename libgm/{binary => gmproto}/conversations.pb.go (99%) rename libgm/{binary => gmproto}/conversations.pb.raw (99%) rename libgm/{binary => gmproto}/conversations.proto (99%) rename libgm/{binary => gmproto}/emojitype.go (98%) rename libgm/{binary => gmproto}/events.pb.go (99%) rename libgm/{binary => gmproto}/events.pb.raw (98%) rename libgm/{binary => gmproto}/events.proto (99%) rename libgm/{binary => gmproto}/media.pb.go (99%) rename libgm/{binary => gmproto}/media.pb.raw (85%) rename libgm/{binary => gmproto}/media.proto (90%) rename libgm/{binary => gmproto}/messages.pb.go (99%) rename libgm/{binary => gmproto}/messages.pb.raw (99%) rename libgm/{binary => gmproto}/messages.proto (99%) rename libgm/{binary => gmproto}/reactions.pb.go (99%) rename libgm/{binary => gmproto}/reactions.pb.raw (96%) rename libgm/{binary => gmproto}/reactions.proto (96%) rename libgm/{binary => gmproto}/responses.pb.go (99%) rename libgm/{binary => gmproto}/responses.pb.raw (97%) rename libgm/{binary => gmproto}/responses.proto (98%) rename libgm/{binary => gmproto}/settings.pb.go (99%) rename libgm/{binary => gmproto}/settings.pb.raw (97%) rename libgm/{binary => gmproto}/settings.proto (97%) diff --git a/database/message.go b/database/message.go index 0c2a2ba..a7a9fb7 100644 --- a/database/message.go +++ b/database/message.go @@ -27,7 +27,7 @@ import ( "maunium.net/go/mautrix/id" "maunium.net/go/mautrix/util/dbutil" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) type MessageQuery struct { @@ -73,7 +73,7 @@ func (mq *MessageQuery) GetLastInChat(ctx context.Context, chat Key) (*Message, } type MessageStatus struct { - Type binary.MessageStatusType + Type gmproto.MessageStatusType } type Message struct { diff --git a/gmtest/main.go b/gmtest/main.go index 9114b83..1b0475f 100644 --- a/gmtest/main.go +++ b/gmtest/main.go @@ -14,8 +14,8 @@ import ( "github.com/rs/zerolog" "go.mau.fi/mautrix-gmessages/libgm" - "go.mau.fi/mautrix-gmessages/libgm/binary" "go.mau.fi/mautrix-gmessages/libgm/events" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) func must(err error) { @@ -128,9 +128,9 @@ func evtHandler(rawEvt any) { log.Debug().Any("data", evt).Msg("Pair successful") saveSession() log.Debug().Msg("Wrote session") - case *binary.Message: + case *gmproto.Message: log.Debug().Any("data", evt).Msg("Message event") - case *binary.Conversation: + case *gmproto.Conversation: log.Debug().Any("data", evt).Msg("Conversation event") case *events.BrowserActive: log.Debug().Any("data", evt).Msg("Browser active") diff --git a/libgm/client.go b/libgm/client.go index 918a62a..34e52fb 100644 --- a/libgm/client.go +++ b/libgm/client.go @@ -16,9 +16,9 @@ import ( "github.com/rs/zerolog" "google.golang.org/protobuf/proto" - "go.mau.fi/mautrix-gmessages/libgm/binary" "go.mau.fi/mautrix-gmessages/libgm/crypto" "go.mau.fi/mautrix-gmessages/libgm/events" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/pblite" "go.mau.fi/mautrix-gmessages/libgm/util" ) @@ -29,8 +29,8 @@ type AuthData struct { // Key used to sign requests to refresh the tachyon auth token from the server RefreshKey *crypto.JWK `json:"refresh_key,omitempty"` // Identity of the paired phone and browser - Browser *binary.Device `json:"browser,omitempty"` - Mobile *binary.Device `json:"mobile,omitempty"` + Browser *gmproto.Device `json:"browser,omitempty"` + Mobile *gmproto.Device `json:"mobile,omitempty"` // Key used to authenticate with the server TachyonAuthToken []byte `json:"tachyon_token,omitempty"` TachyonExpiry time.Time `json:"tachyon_expiry,omitempty"` @@ -146,7 +146,7 @@ func (c *Client) StartLogin() (string, error) { } func (c *Client) GenerateQRCodeData(pairingKey []byte) (string, error) { - urlData := &binary.URLData{ + urlData := &gmproto.URLData{ PairingKey: pairingKey, AESKey: c.AuthData.RequestCrypto.AESKey, HMACKey: c.AuthData.RequestCrypto.HMACKey, @@ -193,12 +193,12 @@ func (c *Client) triggerEvent(evt interface{}) { } func (c *Client) DownloadMedia(mediaID string, key []byte) ([]byte, error) { - downloadMetadata := &binary.UploadImagePayload{ - MetaData: &binary.ImageMetaData{ + downloadMetadata := &gmproto.UploadImagePayload{ + MetaData: &gmproto.ImageMetaData{ ImageID: mediaID, Encrypted: true, }, - AuthData: &binary.AuthMessage{ + AuthData: &gmproto.AuthMessage{ RequestID: uuid.NewString(), TachyonAuthToken: c.AuthData.TachyonAuthToken, ConfigVersion: util.ConfigMessage, @@ -264,7 +264,7 @@ func (c *Client) FetchConfigVersion() { } } -func (c *Client) diffVersionFormat(curr *binary.ConfigVersion, latest *binary.ConfigVersion) string { +func (c *Client) diffVersionFormat(curr *gmproto.ConfigVersion, latest *gmproto.ConfigVersion) string { return fmt.Sprintf("%d.%d.%d -> %d.%d.%d", curr.Year, curr.Month, curr.Day, latest.Year, latest.Month, latest.Day) } @@ -304,8 +304,8 @@ func (c *Client) refreshAuthToken() error { return err } - payload, err := pblite.Marshal(&binary.RegisterRefreshPayload{ - MessageAuth: &binary.AuthMessage{ + payload, err := pblite.Marshal(&gmproto.RegisterRefreshPayload{ + MessageAuth: &gmproto.AuthMessage{ RequestID: requestID, TachyonAuthToken: c.AuthData.TachyonAuthToken, ConfigVersion: util.ConfigMessage, @@ -313,7 +313,7 @@ func (c *Client) refreshAuthToken() error { CurrBrowserDevice: c.AuthData.Browser, UnixTimestamp: timestamp, Signature: sig, - EmptyRefreshArr: &binary.EmptyRefreshArr{EmptyArr: &binary.EmptyArr{}}, + EmptyRefreshArr: &gmproto.EmptyRefreshArr{EmptyArr: &gmproto.EmptyArr{}}, MessageType: 2, // hmm }) if err != nil { @@ -337,7 +337,7 @@ func (c *Client) refreshAuthToken() error { return readErr } - resp := &binary.RegisterRefreshResponse{} + resp := &gmproto.RegisterRefreshResponse{} deserializeErr := pblite.Unmarshal(responseBody, resp) if deserializeErr != nil { return deserializeErr diff --git a/libgm/conversation_builder.go b/libgm/conversation_builder.go index d9823ee..da74c52 100644 --- a/libgm/conversation_builder.go +++ b/libgm/conversation_builder.go @@ -5,7 +5,7 @@ import ( "google.golang.org/protobuf/proto" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) type ConversationBuilderError struct { @@ -19,9 +19,9 @@ func (cbe *ConversationBuilderError) Error() string { type ConversationBuilder struct { conversationId string - actionStatus binary.ConversationActionStatus - status binary.ConversationStatus - muteStatus *binary.ConversationMuteStatus + actionStatus gmproto.ConversationActionStatus + status gmproto.ConversationStatus + muteStatus *gmproto.ConversationMuteStatus } func (cb *ConversationBuilder) SetConversationId(conversationId string) *ConversationBuilder { @@ -30,18 +30,18 @@ func (cb *ConversationBuilder) SetConversationId(conversationId string) *Convers } // For block, unblock, block & report -func (cb *ConversationBuilder) SetConversationActionStatus(actionStatus binary.ConversationActionStatus) *ConversationBuilder { +func (cb *ConversationBuilder) SetConversationActionStatus(actionStatus gmproto.ConversationActionStatus) *ConversationBuilder { cb.actionStatus = actionStatus return cb } // For archive, unarchive, delete -func (cb *ConversationBuilder) SetConversationStatus(status binary.ConversationStatus) *ConversationBuilder { +func (cb *ConversationBuilder) SetConversationStatus(status gmproto.ConversationStatus) *ConversationBuilder { cb.status = status return cb } -func (cb *ConversationBuilder) SetMuteStatus(muteStatus *binary.ConversationMuteStatus) *ConversationBuilder { +func (cb *ConversationBuilder) SetMuteStatus(muteStatus *gmproto.ConversationMuteStatus) *ConversationBuilder { cb.muteStatus = muteStatus return cb } @@ -52,7 +52,7 @@ func (cb *ConversationBuilder) Build(protoMessage proto.Message) (proto.Message, } switch protoMessage.(type) { - case *binary.UpdateConversationPayload: + case *gmproto.UpdateConversationPayload: payload, failedBuild := cb.buildUpdateConversationPayload() if failedBuild != nil { return nil, failedBuild @@ -64,25 +64,25 @@ func (cb *ConversationBuilder) Build(protoMessage proto.Message) (proto.Message, return nil, &ConversationBuilderError{errMsg: "failed to build for unknown reasons"} } -func (cb *ConversationBuilder) buildUpdateConversationPayload() (*binary.UpdateConversationPayload, error) { +func (cb *ConversationBuilder) buildUpdateConversationPayload() (*gmproto.UpdateConversationPayload, error) { if cb.actionStatus == 0 && cb.status == 0 && cb.muteStatus == nil { return nil, &ConversationBuilderError{errMsg: "actionStatus, status & muteStatus can not be empty when updating conversation, set atleast 1"} } - payload := &binary.UpdateConversationPayload{} + payload := &gmproto.UpdateConversationPayload{} if cb.actionStatus != 0 { payload.Action = cb.actionStatus - payload.Action5 = &binary.ConversationAction5{ + payload.Action5 = &gmproto.ConversationAction5{ Field2: true, } payload.ConversationID = cb.conversationId } else if cb.status != 0 || cb.muteStatus != nil { - payload.Data = &binary.UpdateConversationData{ConversationID: cb.conversationId} + payload.Data = &gmproto.UpdateConversationData{ConversationID: cb.conversationId} if cb.muteStatus != nil { - payload.Data.Data = &binary.UpdateConversationData_Mute{Mute: *cb.muteStatus} + payload.Data.Data = &gmproto.UpdateConversationData_Mute{Mute: *cb.muteStatus} } else if cb.status != 0 { - payload.Data.Data = &binary.UpdateConversationData_Status{Status: cb.status} + payload.Data.Data = &gmproto.UpdateConversationData_Status{Status: cb.status} } } diff --git a/libgm/conversations.go b/libgm/conversations.go index 9ba80cb..4c2f25f 100644 --- a/libgm/conversations.go +++ b/libgm/conversations.go @@ -3,184 +3,184 @@ package libgm import ( "fmt" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) -func (c *Client) ListConversations(count int64, folder binary.ListConversationsPayload_Folder) (*binary.Conversations, error) { - payload := &binary.ListConversationsPayload{Count: count, Folder: folder} - //var actionType binary.ActionType +func (c *Client) ListConversations(count int64, folder gmproto.ListConversationsPayload_Folder) (*gmproto.Conversations, error) { + payload := &gmproto.ListConversationsPayload{Count: count, Folder: folder} + //var actionType gmproto.ActionType //if !c.synced { - // actionType = binary.ActionType_LIST_CONVERSATIONS_SYNC + // actionType = gmproto.ActionType_LIST_CONVERSATIONS_SYNC // c.synced = true //} else { - actionType := binary.ActionType_LIST_CONVERSATIONS + actionType := gmproto.ActionType_LIST_CONVERSATIONS response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.Conversations) + res, ok := response.Data.Decrypted.(*gmproto.Conversations) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.Conversations", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.Conversations", response.Data.Decrypted) } return res, nil } -func (c *Client) ListContacts() (*binary.ListContactsResponse, error) { - payload := &binary.ListContactsPayload{ +func (c *Client) ListContacts() (*gmproto.ListContactsResponse, error) { + payload := &gmproto.ListContactsPayload{ I1: 1, I2: 350, I3: 50, } - actionType := binary.ActionType_LIST_CONTACTS + actionType := gmproto.ActionType_LIST_CONTACTS response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.ListContactsResponse) + res, ok := response.Data.Decrypted.(*gmproto.ListContactsResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.ListContactsResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.ListContactsResponse", response.Data.Decrypted) } return res, nil } -func (c *Client) ListTopContacts() (*binary.ListTopContactsResponse, error) { - payload := &binary.ListTopContactsPayload{ +func (c *Client) ListTopContacts() (*gmproto.ListTopContactsResponse, error) { + payload := &gmproto.ListTopContactsPayload{ Count: 8, } - actionType := binary.ActionType_LIST_TOP_CONTACTS + actionType := gmproto.ActionType_LIST_TOP_CONTACTS response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.ListTopContactsResponse) + res, ok := response.Data.Decrypted.(*gmproto.ListTopContactsResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.ListTopContactsResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.ListTopContactsResponse", response.Data.Decrypted) } return res, nil } -func (c *Client) GetOrCreateConversation(req *binary.GetOrCreateConversationPayload) (*binary.GetOrCreateConversationResponse, error) { - actionType := binary.ActionType_GET_OR_CREATE_CONVERSATION +func (c *Client) GetOrCreateConversation(req *gmproto.GetOrCreateConversationPayload) (*gmproto.GetOrCreateConversationResponse, error) { + actionType := gmproto.ActionType_GET_OR_CREATE_CONVERSATION response, err := c.sessionHandler.sendMessage(actionType, req) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.GetOrCreateConversationResponse) + res, ok := response.Data.Decrypted.(*gmproto.GetOrCreateConversationResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.GetOrCreateConversationResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.GetOrCreateConversationResponse", response.Data.Decrypted) } return res, nil } -func (c *Client) GetConversationType(conversationID string) (*binary.GetConversationTypeResponse, error) { - payload := &binary.ConversationTypePayload{ConversationID: conversationID} - actionType := binary.ActionType_GET_CONVERSATION_TYPE +func (c *Client) GetConversationType(conversationID string) (*gmproto.GetConversationTypeResponse, error) { + payload := &gmproto.ConversationTypePayload{ConversationID: conversationID} + actionType := gmproto.ActionType_GET_CONVERSATION_TYPE response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.GetConversationTypeResponse) + res, ok := response.Data.Decrypted.(*gmproto.GetConversationTypeResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.GetConversationTypeResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.GetConversationTypeResponse", response.Data.Decrypted) } return res, nil } -func (c *Client) FetchMessages(conversationID string, count int64, cursor *binary.Cursor) (*binary.FetchMessagesResponse, error) { - payload := &binary.FetchConversationMessagesPayload{ConversationID: conversationID, Count: count} +func (c *Client) FetchMessages(conversationID string, count int64, cursor *gmproto.Cursor) (*gmproto.FetchMessagesResponse, error) { + payload := &gmproto.FetchConversationMessagesPayload{ConversationID: conversationID, Count: count} if cursor != nil { payload.Cursor = cursor } - actionType := binary.ActionType_LIST_MESSAGES + actionType := gmproto.ActionType_LIST_MESSAGES response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.FetchMessagesResponse) + res, ok := response.Data.Decrypted.(*gmproto.FetchMessagesResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.FetchMessagesResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.FetchMessagesResponse", response.Data.Decrypted) } return res, nil } -func (c *Client) SendMessage(payload *binary.SendMessagePayload) (*binary.SendMessageResponse, error) { - actionType := binary.ActionType_SEND_MESSAGE +func (c *Client) SendMessage(payload *gmproto.SendMessagePayload) (*gmproto.SendMessageResponse, error) { + actionType := gmproto.ActionType_SEND_MESSAGE response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.SendMessageResponse) + res, ok := response.Data.Decrypted.(*gmproto.SendMessageResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.SendMessageResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.SendMessageResponse", response.Data.Decrypted) } return res, nil } -func (c *Client) GetParticipantThumbnail(convID string) (*binary.ParticipantThumbnail, error) { - payload := &binary.GetParticipantThumbnailPayload{ConversationID: convID} - actionType := binary.ActionType_GET_PARTICIPANTS_THUMBNAIL +func (c *Client) GetParticipantThumbnail(convID string) (*gmproto.ParticipantThumbnail, error) { + payload := &gmproto.GetParticipantThumbnailPayload{ConversationID: convID} + actionType := gmproto.ActionType_GET_PARTICIPANTS_THUMBNAIL response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.ParticipantThumbnail) + res, ok := response.Data.Decrypted.(*gmproto.ParticipantThumbnail) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.ParticipantThumbnail", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.ParticipantThumbnail", response.Data.Decrypted) } return res, nil } -func (c *Client) UpdateConversation(convBuilder *ConversationBuilder) (*binary.UpdateConversationResponse, error) { - data := &binary.UpdateConversationPayload{} +func (c *Client) UpdateConversation(convBuilder *ConversationBuilder) (*gmproto.UpdateConversationResponse, error) { + data := &gmproto.UpdateConversationPayload{} payload, buildErr := convBuilder.Build(data) if buildErr != nil { panic(buildErr) } - actionType := binary.ActionType_UPDATE_CONVERSATION + actionType := gmproto.ActionType_UPDATE_CONVERSATION response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.UpdateConversationResponse) + res, ok := response.Data.Decrypted.(*gmproto.UpdateConversationResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.UpdateConversationResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.UpdateConversationResponse", response.Data.Decrypted) } return res, nil } func (c *Client) SetTyping(convID string) error { - payload := &binary.TypingUpdatePayload{Data: &binary.SetTypingIn{ConversationID: convID, Typing: true}} - actionType := binary.ActionType_TYPING_UPDATES + payload := &gmproto.TypingUpdatePayload{Data: &gmproto.SetTypingIn{ConversationID: convID, Typing: true}} + actionType := gmproto.ActionType_TYPING_UPDATES _, err := c.sessionHandler.sendMessage(actionType, payload) return err diff --git a/libgm/event_handler.go b/libgm/event_handler.go index c9371e5..57f9409 100644 --- a/libgm/event_handler.go +++ b/libgm/event_handler.go @@ -6,7 +6,7 @@ import ( "go.mau.fi/mautrix-gmessages/libgm/pblite" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) func (r *RPC) deduplicateHash(hash [32]byte) bool { @@ -42,7 +42,7 @@ func (r *RPC) deduplicateUpdate(response *pblite.Response) bool { return false } -func (r *RPC) HandleRPCMsg(msg *binary.InternalMessage) { +func (r *RPC) HandleRPCMsg(msg *gmproto.InternalMessage) { response, decodeErr := pblite.DecryptInternalMessage(msg, r.client.AuthData.RequestCrypto) if decodeErr != nil { r.client.Logger.Error().Err(decodeErr).Msg("rpc decrypt msg err") @@ -58,9 +58,9 @@ func (r *RPC) HandleRPCMsg(msg *binary.InternalMessage) { return } switch response.BugleRoute { - case binary.BugleRoute_PairEvent: + case gmproto.BugleRoute_PairEvent: go r.client.handlePairingEvent(response) - case binary.BugleRoute_DataEvent: + case gmproto.BugleRoute_DataEvent: if r.skipCount > 0 { r.skipCount-- r.client.Logger.Debug(). diff --git a/libgm/events/qr.go b/libgm/events/qr.go index 1efb94b..2f95175 100644 --- a/libgm/events/qr.go +++ b/libgm/events/qr.go @@ -1,7 +1,7 @@ package events import ( - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) type QR struct { @@ -9,5 +9,5 @@ type QR struct { } type PairSuccessful struct { - *binary.PairedData + *gmproto.PairedData } diff --git a/libgm/events/ready.go b/libgm/events/ready.go index 1986ae0..d651388 100644 --- a/libgm/events/ready.go +++ b/libgm/events/ready.go @@ -4,15 +4,15 @@ import ( "fmt" "net/http" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) type ClientReady struct { SessionID string - Conversations []*binary.Conversation + Conversations []*gmproto.Conversation } -func NewClientReady(sessionID string, conversationList *binary.Conversations) *ClientReady { +func NewClientReady(sessionID string, conversationList *gmproto.Conversations) *ClientReady { return &ClientReady{ SessionID: sessionID, Conversations: conversationList.Conversations, diff --git a/libgm/binary/authentication.pb.go b/libgm/gmproto/authentication.pb.go similarity index 99% rename from libgm/binary/authentication.pb.go rename to libgm/gmproto/authentication.pb.go index 79b7cb7..f748869 100644 --- a/libgm/binary/authentication.pb.go +++ b/libgm/gmproto/authentication.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: authentication.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/authentication.pb.raw b/libgm/gmproto/authentication.pb.raw similarity index 94% rename from libgm/binary/authentication.pb.raw rename to libgm/gmproto/authentication.pb.raw index c24ab4515192c466567b9e1af814c0737360830e..ab5f458f4ef49e5d1f0583e7a0a585e126dce371 100644 GIT binary patch delta 29 hcmcb_b(w2}9jho$6qlZ!etK>}QGQ8&5*wH@1^|os36uZ; delta 28 jcmcc2b%|?(9jgd;6sMk^eo|&$Vo_xhTR~BNNxm@vfPo1P diff --git a/libgm/binary/authentication.proto b/libgm/gmproto/authentication.proto similarity index 97% rename from libgm/binary/authentication.proto rename to libgm/gmproto/authentication.proto index c73fc80..bb86bfa 100644 --- a/libgm/binary/authentication.proto +++ b/libgm/gmproto/authentication.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package authentication; -option go_package = "../binary"; +option go_package = "../gmproto"; import "messages.proto"; import "client.proto"; diff --git a/libgm/binary/client.pb.go b/libgm/gmproto/client.pb.go similarity index 99% rename from libgm/binary/client.pb.go rename to libgm/gmproto/client.pb.go index 0c6536a..05b50ee 100644 --- a/libgm/binary/client.pb.go +++ b/libgm/gmproto/client.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: client.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/client.pb.raw b/libgm/gmproto/client.pb.raw similarity index 97% rename from libgm/binary/client.pb.raw rename to libgm/gmproto/client.pb.raw index b5c063df7e55c9c81da90f90efe8051824a370ce..e304e70ae2b7f44d927d60f00db7404a4a78e34e 100644 GIT binary patch delta 29 hcmeyv@t0#m28$?96qlZ!etK>}QGQ8&5*wH@1^}3r3Jm}N delta 28 jcmey%@rPqW28#%H6sMk^eo|&$Vo_xhTR~BNNxm@vjHL;O diff --git a/libgm/binary/client.proto b/libgm/gmproto/client.proto similarity index 97% rename from libgm/binary/client.proto rename to libgm/gmproto/client.proto index 2226ab9..d25e51e 100644 --- a/libgm/binary/client.proto +++ b/libgm/gmproto/client.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package client; -option go_package = "../binary"; +option go_package = "../gmproto"; import "messages.proto"; diff --git a/libgm/binary/conversations.pb.go b/libgm/gmproto/conversations.pb.go similarity index 99% rename from libgm/binary/conversations.pb.go rename to libgm/gmproto/conversations.pb.go index ba9b0da..32c690b 100644 --- a/libgm/binary/conversations.pb.go +++ b/libgm/gmproto/conversations.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: conversations.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/conversations.pb.raw b/libgm/gmproto/conversations.pb.raw similarity index 99% rename from libgm/binary/conversations.pb.raw rename to libgm/gmproto/conversations.pb.raw index 9963b5810e21cd9a17973307250b995f496d218e..532c3f43095ccbf2ef676985b43daf76d37239e9 100644 GIT binary patch delta 29 hcmdlPx+`?UQY}%QC@wuc{q)>|qWqHlBsMT*3;?4}3WNXv delta 28 jcmdlLx-)dcQY{hgC{8^+{iMvi#G=Y1wt}Mkl6+$TmgWim diff --git a/libgm/binary/conversations.proto b/libgm/gmproto/conversations.proto similarity index 99% rename from libgm/binary/conversations.proto rename to libgm/gmproto/conversations.proto index 3040e5a..4b959ab 100644 --- a/libgm/binary/conversations.proto +++ b/libgm/gmproto/conversations.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package conversations; -option go_package = "../binary"; +option go_package = "../gmproto"; import "reactions.proto"; diff --git a/libgm/binary/emojitype.go b/libgm/gmproto/emojitype.go similarity index 98% rename from libgm/binary/emojitype.go rename to libgm/gmproto/emojitype.go index 517ff0b..8830f33 100644 --- a/libgm/binary/emojitype.go +++ b/libgm/gmproto/emojitype.go @@ -1,4 +1,4 @@ -package binary +package gmproto func (et EmojiType) Unicode() string { switch et { diff --git a/libgm/binary/events.pb.go b/libgm/gmproto/events.pb.go similarity index 99% rename from libgm/binary/events.pb.go rename to libgm/gmproto/events.pb.go index 57d42ca..354289b 100644 --- a/libgm/binary/events.pb.go +++ b/libgm/gmproto/events.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: events.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/events.pb.raw b/libgm/gmproto/events.pb.raw similarity index 98% rename from libgm/binary/events.pb.raw rename to libgm/gmproto/events.pb.raw index f66f8416801d03ca393e14c8553413b9c289e95e..b7d99608a9456745ce1c0b54e8a54c1b5c1171c5 100644 GIT binary patch delta 29 hcmbQsKaYPyC%Y(56qlZ!etK>}QGQ8&5*wH@1^|eq34s6r delta 28 jcmbQoKbL<)C%XuD6sMk^eo|&$Vo_xhTR~BNNxm@veLx8N diff --git a/libgm/binary/events.proto b/libgm/gmproto/events.proto similarity index 99% rename from libgm/binary/events.proto rename to libgm/gmproto/events.proto index 364af14..f41e8b0 100644 --- a/libgm/binary/events.proto +++ b/libgm/gmproto/events.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package events; -option go_package = "../binary"; +option go_package = "../gmproto"; import "conversations.proto"; import "authentication.proto"; diff --git a/libgm/binary/media.pb.go b/libgm/gmproto/media.pb.go similarity index 99% rename from libgm/binary/media.pb.go rename to libgm/gmproto/media.pb.go index 638fdb0..a13c92e 100644 --- a/libgm/binary/media.pb.go +++ b/libgm/gmproto/media.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: media.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/media.pb.raw b/libgm/gmproto/media.pb.raw similarity index 85% rename from libgm/binary/media.pb.raw rename to libgm/gmproto/media.pb.raw index d63b63fc353631c5326ce4c385504cb1d38ebc76..455b5f8d49977f4dee7cbd4a84dc687964943437 100644 GIT binary patch delta 29 hcmaFG^qOfy7^5gp6qlZ!etK>}QGQ8&5*wH@1^|(53CI8d delta 28 jcmaFO^onUi7^4Vx6sMk^eo|&$Vo_xhTR~BNNxm@vg~16z diff --git a/libgm/binary/media.proto b/libgm/gmproto/media.proto similarity index 90% rename from libgm/binary/media.proto rename to libgm/gmproto/media.proto index f788636..5cc54af 100644 --- a/libgm/binary/media.proto +++ b/libgm/gmproto/media.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package media; -option go_package = "../binary"; +option go_package = "../gmproto"; import "messages.proto"; diff --git a/libgm/binary/messages.pb.go b/libgm/gmproto/messages.pb.go similarity index 99% rename from libgm/binary/messages.pb.go rename to libgm/gmproto/messages.pb.go index b39746f..b371267 100644 --- a/libgm/binary/messages.pb.go +++ b/libgm/gmproto/messages.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: messages.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/messages.pb.raw b/libgm/gmproto/messages.pb.raw similarity index 99% rename from libgm/binary/messages.pb.raw rename to libgm/gmproto/messages.pb.raw index e25cf51c35f9de633f59b791f5773e69d5330a2d..72bbcbf883c16d21088fd28cc8ebd9a9f93fa9d7 100644 GIT binary patch delta 29 hcmbQKGD~FxtB@#96qlZ!etK>}QGQ8&5*wH@1^|H22`T^p delta 28 jcmbQGGE-#(tB?qH6sMk^eo|&$Vo_xhTR~BNNxm@vb;1aw diff --git a/libgm/binary/messages.proto b/libgm/gmproto/messages.proto similarity index 99% rename from libgm/binary/messages.proto rename to libgm/gmproto/messages.proto index 84d6902..39f33d3 100644 --- a/libgm/binary/messages.proto +++ b/libgm/gmproto/messages.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package messages; -option go_package = "../binary"; +option go_package = "../gmproto"; message RegisterRefreshPayload { AuthMessage messageAuth = 1; diff --git a/libgm/binary/reactions.pb.go b/libgm/gmproto/reactions.pb.go similarity index 99% rename from libgm/binary/reactions.pb.go rename to libgm/gmproto/reactions.pb.go index b727d86..d36983a 100644 --- a/libgm/binary/reactions.pb.go +++ b/libgm/gmproto/reactions.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: reactions.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/reactions.pb.raw b/libgm/gmproto/reactions.pb.raw similarity index 96% rename from libgm/binary/reactions.pb.raw rename to libgm/gmproto/reactions.pb.raw index 74811ef1206970ab63b381ee3b8b15383202078d..8e77980414dfdffdff62dc79955e73ec80f439f8 100644 GIT binary patch delta 29 hcmcc4c7tt$GqWg96qlZ!etK>}QGQ8&5*wH@1^|qM37G%@ delta 28 jcmcb?cAag5GqVVH6sMk^eo|&$Vo_xhTR~BNNxm@vfd&Z^ diff --git a/libgm/binary/reactions.proto b/libgm/gmproto/reactions.proto similarity index 96% rename from libgm/binary/reactions.proto rename to libgm/gmproto/reactions.proto index 56895f6..ea6c428 100644 --- a/libgm/binary/reactions.proto +++ b/libgm/gmproto/reactions.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package reactions; -option go_package = "../binary"; +option go_package = "../gmproto"; enum Reaction { UNSPECIFIED = 0; diff --git a/libgm/binary/responses.pb.go b/libgm/gmproto/responses.pb.go similarity index 99% rename from libgm/binary/responses.pb.go rename to libgm/gmproto/responses.pb.go index c8b2bba..738e9a8 100644 --- a/libgm/binary/responses.pb.go +++ b/libgm/gmproto/responses.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: responses.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/responses.pb.raw b/libgm/gmproto/responses.pb.raw similarity index 97% rename from libgm/binary/responses.pb.raw rename to libgm/gmproto/responses.pb.raw index 61c6fbbb908cc5361fe4a0e132616cc2f6d4d3a4..74abb0eac79383c8df10255dbe45893dc9f7d405 100644 GIT binary patch delta 29 hcmew<_)BoZQw~v{C@wuc{q)>|qWqHlBsMT*3;?C*3Yq`_ delta 28 jcmew*_)~DhQw|aCC{8^+{iMvi#G=Y1wt}Mkl6+$TnQ96Y diff --git a/libgm/binary/responses.proto b/libgm/gmproto/responses.proto similarity index 98% rename from libgm/binary/responses.proto rename to libgm/gmproto/responses.proto index 591d597..6886701 100644 --- a/libgm/binary/responses.proto +++ b/libgm/gmproto/responses.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package responses; -option go_package = "../binary"; +option go_package = "../gmproto"; import "events.proto"; import "messages.proto"; diff --git a/libgm/binary/settings.pb.go b/libgm/gmproto/settings.pb.go similarity index 99% rename from libgm/binary/settings.pb.go rename to libgm/gmproto/settings.pb.go index 2bcf948..2fcd7d4 100644 --- a/libgm/binary/settings.pb.go +++ b/libgm/gmproto/settings.pb.go @@ -4,7 +4,7 @@ // protoc v3.21.12 // source: settings.proto -package binary +package gmproto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" diff --git a/libgm/binary/settings.pb.raw b/libgm/gmproto/settings.pb.raw similarity index 97% rename from libgm/binary/settings.pb.raw rename to libgm/gmproto/settings.pb.raw index 6b2a390eeb81671153f760f442024dd8250873c5..d2b78593e4cfcb9c298fd7aa279b6bdd9b1225f4 100644 GIT binary patch delta 29 hcmcb}bBSkzEt@D$6qlZ!etK>}QGQ8&5*wH@1^|pK36=l= delta 28 jcmcb_bCG9*Et?2;6sMk^eo|&$Vo_xhTR~BNNxm@vfU*e? diff --git a/libgm/binary/settings.proto b/libgm/gmproto/settings.proto similarity index 97% rename from libgm/binary/settings.proto rename to libgm/gmproto/settings.proto index b5d45fe..51a2da7 100644 --- a/libgm/binary/settings.proto +++ b/libgm/gmproto/settings.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package settings; -option go_package = "../binary"; +option go_package = "../gmproto"; message Settings { diff --git a/libgm/messages.go b/libgm/messages.go index bd506a0..db99c9d 100644 --- a/libgm/messages.go +++ b/libgm/messages.go @@ -3,45 +3,45 @@ package libgm import ( "fmt" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) -func (c *Client) SendReaction(payload *binary.SendReactionPayload) (*binary.SendReactionResponse, error) { - actionType := binary.ActionType_SEND_REACTION +func (c *Client) SendReaction(payload *gmproto.SendReactionPayload) (*gmproto.SendReactionResponse, error) { + actionType := gmproto.ActionType_SEND_REACTION response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.SendReactionResponse) + res, ok := response.Data.Decrypted.(*gmproto.SendReactionResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.SendReactionResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.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 +func (c *Client) DeleteMessage(messageID string) (*gmproto.DeleteMessageResponse, error) { + payload := &gmproto.DeleteMessagePayload{MessageID: messageID} + actionType := gmproto.ActionType_DELETE_MESSAGE response, err := c.sessionHandler.sendMessage(actionType, payload) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.DeleteMessageResponse) + res, ok := response.Data.Decrypted.(*gmproto.DeleteMessageResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.DeleteMessagesResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.DeleteMessagesResponse", response.Data.Decrypted) } return res, nil } func (c *Client) MarkRead(conversationID, messageID string) error { - payload := &binary.MessageReadPayload{ConversationID: conversationID, MessageID: messageID} - actionType := binary.ActionType_MESSAGE_READ + payload := &gmproto.MessageReadPayload{ConversationID: conversationID, MessageID: messageID} + actionType := gmproto.ActionType_MESSAGE_READ _, err := c.sessionHandler.sendMessage(actionType, payload) return err diff --git a/libgm/pair.go b/libgm/pair.go index 3709a6b..b2024c9 100644 --- a/libgm/pair.go +++ b/libgm/pair.go @@ -7,26 +7,26 @@ import ( "github.com/google/uuid" "google.golang.org/protobuf/proto" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/util" ) -func (c *Client) RegisterPhoneRelay() (*binary.RegisterPhoneRelayResponse, error) { +func (c *Client) RegisterPhoneRelay() (*gmproto.RegisterPhoneRelayResponse, error) { key, err := x509.MarshalPKIXPublicKey(c.AuthData.RefreshKey.GetPublicKey()) if err != nil { return nil, err } - body, err := proto.Marshal(&binary.AuthenticationContainer{ - AuthMessage: &binary.AuthMessage{ + body, err := proto.Marshal(&gmproto.AuthenticationContainer{ + AuthMessage: &gmproto.AuthMessage{ RequestID: uuid.NewString(), Network: &util.Network, ConfigVersion: util.ConfigMessage, }, BrowserDetails: util.BrowserDetailsMessage, - Data: &binary.AuthenticationContainer_KeyData{ - KeyData: &binary.KeyData{ - EcdsaKeys: &binary.ECDSAKeys{ + Data: &gmproto.AuthenticationContainer_KeyData{ + KeyData: &gmproto.KeyData{ + EcdsaKeys: &gmproto.ECDSAKeys{ Field1: 2, EncryptedKeys: key, }, @@ -45,7 +45,7 @@ func (c *Client) RegisterPhoneRelay() (*binary.RegisterPhoneRelayResponse, error return nil, err } relayResponse.Body.Close() - res := &binary.RegisterPhoneRelayResponse{} + res := &gmproto.RegisterPhoneRelayResponse{} err = proto.Unmarshal(responseBody, res) if err != nil { return nil, err @@ -54,8 +54,8 @@ func (c *Client) RegisterPhoneRelay() (*binary.RegisterPhoneRelayResponse, error } func (c *Client) RefreshPhoneRelay() (string, error) { - body, err := proto.Marshal(&binary.AuthenticationContainer{ - AuthMessage: &binary.AuthMessage{ + body, err := proto.Marshal(&gmproto.AuthenticationContainer{ + AuthMessage: &gmproto.AuthMessage{ RequestID: uuid.NewString(), Network: &util.Network, TachyonAuthToken: c.AuthData.TachyonAuthToken, @@ -74,7 +74,7 @@ func (c *Client) RefreshPhoneRelay() (string, error) { if err != nil { return "", err } - res := &binary.RefreshPhoneRelayResponse{} + res := &gmproto.RefreshPhoneRelayResponse{} err = proto.Unmarshal(responseBody, res) if err != nil { return "", err @@ -86,9 +86,9 @@ func (c *Client) RefreshPhoneRelay() (string, error) { return qr, nil } -func (c *Client) GetWebEncryptionKey() (*binary.WebEncryptionKeyResponse, error) { - body, err := proto.Marshal(&binary.AuthenticationContainer{ - AuthMessage: &binary.AuthMessage{ +func (c *Client) GetWebEncryptionKey() (*gmproto.WebEncryptionKeyResponse, error) { + body, err := proto.Marshal(&gmproto.AuthenticationContainer{ + AuthMessage: &gmproto.AuthMessage{ RequestID: uuid.NewString(), TachyonAuthToken: c.AuthData.TachyonAuthToken, ConfigVersion: util.ConfigMessage, @@ -106,7 +106,7 @@ func (c *Client) GetWebEncryptionKey() (*binary.WebEncryptionKeyResponse, error) if err != nil { return nil, err } - parsedResponse := &binary.WebEncryptionKeyResponse{} + parsedResponse := &gmproto.WebEncryptionKeyResponse{} err = proto.Unmarshal(responseBody, parsedResponse) if err != nil { return nil, err @@ -114,12 +114,12 @@ func (c *Client) GetWebEncryptionKey() (*binary.WebEncryptionKeyResponse, error) return parsedResponse, nil } -func (c *Client) Unpair() (*binary.RevokeRelayPairingResponse, error) { +func (c *Client) Unpair() (*gmproto.RevokeRelayPairingResponse, error) { if c.AuthData.TachyonAuthToken == nil || c.AuthData.Browser == nil { return nil, nil } - payload, err := proto.Marshal(&binary.RevokeRelayPairing{ - AuthMessage: &binary.AuthMessage{ + payload, err := proto.Marshal(&gmproto.RevokeRelayPairing{ + AuthMessage: &gmproto.AuthMessage{ RequestID: uuid.NewString(), TachyonAuthToken: c.AuthData.TachyonAuthToken, ConfigVersion: util.ConfigMessage, @@ -138,7 +138,7 @@ func (c *Client) Unpair() (*binary.RevokeRelayPairingResponse, error) { if err != nil { return nil, err } - parsedResponse := &binary.RevokeRelayPairingResponse{} + parsedResponse := &gmproto.RevokeRelayPairingResponse{} err = proto.Unmarshal(responseBody, parsedResponse) if err != nil { return nil, err diff --git a/libgm/pairing_handler.go b/libgm/pairing_handler.go index 9f74caa..3ea3cf5 100644 --- a/libgm/pairing_handler.go +++ b/libgm/pairing_handler.go @@ -6,27 +6,27 @@ import ( "go.mau.fi/mautrix-gmessages/libgm/events" "go.mau.fi/mautrix-gmessages/libgm/pblite" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) func (c *Client) handlePairingEvent(response *pblite.Response) { - pairEventData, ok := response.Data.Decrypted.(*binary.PairEvents) + pairEventData, ok := response.Data.Decrypted.(*gmproto.PairEvents) if !ok { c.Logger.Error().Type("decrypted_type", response.Data.Decrypted).Msg("Unexpected data type in pair event") return } switch evt := pairEventData.Event.(type) { - case *binary.PairEvents_Paired: + case *gmproto.PairEvents_Paired: c.completePairing(evt.Paired) - case *binary.PairEvents_Revoked: + case *gmproto.PairEvents_Revoked: c.triggerEvent(evt.Revoked) default: c.Logger.Debug().Any("evt", evt).Msg("Unknown pair event type") } } -func (c *Client) completePairing(data *binary.PairedData) { +func (c *Client) completePairing(data *gmproto.PairedData) { c.updateTachyonAuthToken(data.GetTokenData().GetTachyonAuthToken(), data.GetTokenData().GetTTL()) c.AuthData.Mobile = data.Mobile c.AuthData.Browser = data.Browser diff --git a/libgm/payload/sendMessage.go b/libgm/payload/sendMessage.go index 3a59c03..6934fdf 100644 --- a/libgm/payload/sendMessage.go +++ b/libgm/payload/sendMessage.go @@ -5,16 +5,16 @@ import ( "google.golang.org/protobuf/proto" - "go.mau.fi/mautrix-gmessages/libgm/binary" "go.mau.fi/mautrix-gmessages/libgm/crypto" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/pblite" "go.mau.fi/mautrix-gmessages/libgm/routes" "go.mau.fi/mautrix-gmessages/libgm/util" ) type SendMessageBuilder struct { - message *binary.SendMessage - b64Message *binary.SendMessageInternal + message *gmproto.SendMessage + b64Message *gmproto.SendMessageInternal err error } @@ -23,33 +23,33 @@ func (sm *SendMessageBuilder) Err() error { return sm.err } -func NewSendMessageBuilder(tachyonAuthToken []byte, pairedDevice *binary.Device, requestId string, sessionId string) *SendMessageBuilder { +func NewSendMessageBuilder(tachyonAuthToken []byte, pairedDevice *gmproto.Device, requestId string, sessionId string) *SendMessageBuilder { return &SendMessageBuilder{ - message: &binary.SendMessage{ + message: &gmproto.SendMessage{ Mobile: pairedDevice, - MessageData: &binary.SendMessageData{ + MessageData: &gmproto.SendMessageData{ RequestID: requestId, }, - MessageAuth: &binary.SendMessageAuth{ + MessageAuth: &gmproto.SendMessageAuth{ RequestID: requestId, TachyonAuthToken: tachyonAuthToken, ConfigVersion: util.ConfigMessage, }, - EmptyArr: &binary.EmptyArr{}, + EmptyArr: &gmproto.EmptyArr{}, }, - b64Message: &binary.SendMessageInternal{ + b64Message: &gmproto.SendMessageInternal{ RequestID: requestId, SessionID: sessionId, }, } } -func (sm *SendMessageBuilder) SetPairedDevice(device *binary.Device) *SendMessageBuilder { +func (sm *SendMessageBuilder) SetPairedDevice(device *gmproto.Device) *SendMessageBuilder { sm.message.Mobile = device return sm } -func (sm *SendMessageBuilder) setBugleRoute(bugleRoute binary.BugleRoute) *SendMessageBuilder { +func (sm *SendMessageBuilder) setBugleRoute(bugleRoute gmproto.BugleRoute) *SendMessageBuilder { sm.message.MessageData.BugleRoute = bugleRoute return sm } @@ -66,7 +66,7 @@ func (sm *SendMessageBuilder) SetSessionId(sessionId string) *SendMessageBuilder return sm } -func (sm *SendMessageBuilder) SetRoute(actionType binary.ActionType) *SendMessageBuilder { +func (sm *SendMessageBuilder) SetRoute(actionType gmproto.ActionType) *SendMessageBuilder { action, ok := routes.Routes[actionType] if !ok { sm.err = fmt.Errorf("invalid action type") @@ -79,9 +79,9 @@ func (sm *SendMessageBuilder) SetRoute(actionType binary.ActionType) *SendMessag return sm } -func (sm *SendMessageBuilder) setMessageType(eventType binary.MessageType) *SendMessageBuilder { - sm.message.MessageData.MessageTypeData = &binary.MessageTypeData{ - EmptyArr: &binary.EmptyArr{}, +func (sm *SendMessageBuilder) setMessageType(eventType gmproto.MessageType) *SendMessageBuilder { + sm.message.MessageData.MessageTypeData = &gmproto.MessageTypeData{ + EmptyArr: &gmproto.EmptyArr{}, MessageType: eventType, } return sm diff --git a/libgm/pblite/internal.go b/libgm/pblite/internal.go index 81e19e8..f619607 100644 --- a/libgm/pblite/internal.go +++ b/libgm/pblite/internal.go @@ -4,53 +4,53 @@ import ( "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" - "go.mau.fi/mautrix-gmessages/libgm/binary" "go.mau.fi/mautrix-gmessages/libgm/crypto" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/routes" ) type DevicePair struct { - Mobile *binary.Device `json:"mobile,omitempty"` - Browser *binary.Device `json:"browser,omitempty"` + Mobile *gmproto.Device `json:"mobile,omitempty"` + Browser *gmproto.Device `json:"browser,omitempty"` } type RequestData struct { - RequestID string `json:"requestId,omitempty"` - Timestamp int64 `json:"timestamp,omitempty"` - Action binary.ActionType `json:"action,omitempty"` - Bool1 bool `json:"bool1,omitempty"` - Bool2 bool `json:"bool2,omitempty"` - EncryptedData []byte `json:"requestData,omitempty"` - RawDecrypted []byte `json:"-,omitempty"` - Decrypted proto.Message `json:"decrypted,omitempty"` - Bool3 bool `json:"bool3,omitempty"` + RequestID string `json:"requestId,omitempty"` + Timestamp int64 `json:"timestamp,omitempty"` + Action gmproto.ActionType `json:"action,omitempty"` + Bool1 bool `json:"bool1,omitempty"` + Bool2 bool `json:"bool2,omitempty"` + EncryptedData []byte `json:"requestData,omitempty"` + RawDecrypted []byte `json:"-,omitempty"` + Decrypted proto.Message `json:"decrypted,omitempty"` + Bool3 bool `json:"bool3,omitempty"` } type Response struct { - ResponseID string `json:"responseId,omitempty"` - BugleRoute binary.BugleRoute `json:"bugleRoute,omitempty"` - StartExecute string `json:"startExecute,omitempty"` - MessageType binary.MessageType `json:"eventType,omitempty"` - FinishExecute string `json:"finishExecute,omitempty"` - MillisecondsTaken string `json:"millisecondsTaken,omitempty"` - Devices *DevicePair `json:"devices,omitempty"` - Data RequestData `json:"data,omitempty"` - SignatureId string `json:"signatureId,omitempty"` - Timestamp string `json:"timestamp"` + ResponseID string `json:"responseId,omitempty"` + BugleRoute gmproto.BugleRoute `json:"bugleRoute,omitempty"` + StartExecute string `json:"startExecute,omitempty"` + MessageType gmproto.MessageType `json:"eventType,omitempty"` + FinishExecute string `json:"finishExecute,omitempty"` + MillisecondsTaken string `json:"millisecondsTaken,omitempty"` + Devices *DevicePair `json:"devices,omitempty"` + Data RequestData `json:"data,omitempty"` + SignatureId string `json:"signatureId,omitempty"` + Timestamp string `json:"timestamp"` } -func DecryptInternalMessage(internalMessage *binary.InternalMessage, cryptor *crypto.AESCTRHelper) (*Response, error) { +func DecryptInternalMessage(internalMessage *gmproto.InternalMessage, cryptor *crypto.AESCTRHelper) (*Response, error) { var resp *Response switch internalMessage.Data.BugleRoute { - case binary.BugleRoute_PairEvent: - decodedData := &binary.PairEvents{} + case gmproto.BugleRoute_PairEvent: + decodedData := &gmproto.PairEvents{} decodeErr := proto.Unmarshal(internalMessage.Data.ProtobufData, decodedData) if decodeErr != nil { return nil, decodeErr } resp = newResponseFromPairEvent(internalMessage.GetData(), decodedData) - case binary.BugleRoute_DataEvent: - internalRequestData := &binary.InternalRequestData{} + case gmproto.BugleRoute_DataEvent: + internalRequestData := &gmproto.InternalRequestData{} decodeErr := proto.Unmarshal(internalMessage.Data.ProtobufData, internalRequestData) if decodeErr != nil { return nil, decodeErr @@ -74,7 +74,7 @@ func DecryptInternalMessage(internalMessage *binary.InternalMessage, cryptor *cr return resp, nil } -func newResponseFromPairEvent(internalMsg *binary.InternalMessageData, data *binary.PairEvents) *Response { +func newResponseFromPairEvent(internalMsg *gmproto.InternalMessageData, data *gmproto.PairEvents) *Response { resp := &Response{ ResponseID: internalMsg.GetResponseID(), BugleRoute: internalMsg.GetBugleRoute(), @@ -96,7 +96,7 @@ func newResponseFromPairEvent(internalMsg *binary.InternalMessageData, data *bin return resp } -func newResponseFromDataEvent(internalMsg *binary.InternalMessageData, internalRequestData *binary.InternalRequestData, rawData []byte, decrypted protoreflect.ProtoMessage) *Response { +func newResponseFromDataEvent(internalMsg *gmproto.InternalMessageData, internalRequestData *gmproto.InternalRequestData, rawData []byte, decrypted protoreflect.ProtoMessage) *Response { resp := &Response{ ResponseID: internalMsg.GetResponseID(), BugleRoute: internalMsg.GetBugleRoute(), diff --git a/libgm/routes/conversations.go b/libgm/routes/conversations.go index 02adf15..44e9ea6 100644 --- a/libgm/routes/conversations.go +++ b/libgm/routes/conversations.go @@ -1,56 +1,56 @@ package routes -import "go.mau.fi/mautrix-gmessages/libgm/binary" +import "go.mau.fi/mautrix-gmessages/libgm/gmproto" var LIST_CONVERSATIONS_WITH_UPDATES = Route{ - Action: binary.ActionType_LIST_CONVERSATIONS, - MessageType: binary.MessageType_BUGLE_ANNOTATION, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.Conversations{}, + Action: gmproto.ActionType_LIST_CONVERSATIONS, + MessageType: gmproto.MessageType_BUGLE_ANNOTATION, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.Conversations{}, UseSessionID: false, UseTTL: true, } var LIST_CONVERSATIONS = Route{ - Action: binary.ActionType_LIST_CONVERSATIONS, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.Conversations{}, + Action: gmproto.ActionType_LIST_CONVERSATIONS, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.Conversations{}, UseSessionID: false, UseTTL: true, } var GET_CONVERSATION_TYPE = Route{ - Action: binary.ActionType_GET_CONVERSATION_TYPE, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.GetConversationTypeResponse{}, + Action: gmproto.ActionType_GET_CONVERSATION_TYPE, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.GetConversationTypeResponse{}, UseSessionID: false, UseTTL: true, } var GET_PARTICIPANT_THUMBNAIL = Route{ - Action: binary.ActionType_GET_PARTICIPANTS_THUMBNAIL, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.ParticipantThumbnail{}, + Action: gmproto.ActionType_GET_PARTICIPANTS_THUMBNAIL, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.ParticipantThumbnail{}, UseSessionID: false, UseTTL: true, } var UPDATE_CONVERSATION = Route{ - Action: binary.ActionType_UPDATE_CONVERSATION, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.UpdateConversationResponse{}, + Action: gmproto.ActionType_UPDATE_CONVERSATION, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.UpdateConversationResponse{}, UseSessionID: false, UseTTL: true, } var TYPING_UPDATES = Route{ - Action: binary.ActionType_TYPING_UPDATES, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, + Action: gmproto.ActionType_TYPING_UPDATES, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, ResponseStruct: nil, UseSessionID: false, UseTTL: true, diff --git a/libgm/routes/mapped.go b/libgm/routes/mapped.go index dbc67d2..81d0030 100644 --- a/libgm/routes/mapped.go +++ b/libgm/routes/mapped.go @@ -3,33 +3,33 @@ package routes import ( "google.golang.org/protobuf/proto" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) type Route struct { - Action binary.ActionType - MessageType binary.MessageType - BugleRoute binary.BugleRoute + Action gmproto.ActionType + MessageType gmproto.MessageType + BugleRoute gmproto.BugleRoute ResponseStruct proto.Message UseSessionID bool UseTTL bool } -var Routes = map[binary.ActionType]Route{ - binary.ActionType_IS_BUGLE_DEFAULT: IS_BUGLE_DEFAULT, - binary.ActionType_GET_UPDATES: GET_UPDATES, - binary.ActionType_LIST_CONVERSATIONS: LIST_CONVERSATIONS, - binary.ActionType_LIST_CONVERSATIONS_SYNC: LIST_CONVERSATIONS_WITH_UPDATES, - binary.ActionType_MESSAGE_READ: MESSAGE_READ, - binary.ActionType_NOTIFY_DITTO_ACTIVITY: NOTIFY_DITTO_ACTIVITY, - binary.ActionType_GET_CONVERSATION_TYPE: GET_CONVERSATION_TYPE, - binary.ActionType_LIST_MESSAGES: LIST_MESSAGES, - binary.ActionType_SEND_MESSAGE: SEND_MESSAGE, - binary.ActionType_SEND_REACTION: SEND_REACTION, - binary.ActionType_DELETE_MESSAGE: DELETE_MESSAGE, - binary.ActionType_TYPING_UPDATES: TYPING_UPDATES, - binary.ActionType_GET_PARTICIPANTS_THUMBNAIL: GET_PARTICIPANT_THUMBNAIL, - binary.ActionType_LIST_CONTACTS: LIST_CONTACTS, - binary.ActionType_LIST_TOP_CONTACTS: LIST_TOP_CONTACTS, - binary.ActionType_GET_OR_CREATE_CONVERSATION: GET_OR_CREATE_CONVERSATION, +var Routes = map[gmproto.ActionType]Route{ + gmproto.ActionType_IS_BUGLE_DEFAULT: IS_BUGLE_DEFAULT, + gmproto.ActionType_GET_UPDATES: GET_UPDATES, + gmproto.ActionType_LIST_CONVERSATIONS: LIST_CONVERSATIONS, + gmproto.ActionType_LIST_CONVERSATIONS_SYNC: LIST_CONVERSATIONS_WITH_UPDATES, + gmproto.ActionType_MESSAGE_READ: MESSAGE_READ, + gmproto.ActionType_NOTIFY_DITTO_ACTIVITY: NOTIFY_DITTO_ACTIVITY, + gmproto.ActionType_GET_CONVERSATION_TYPE: GET_CONVERSATION_TYPE, + gmproto.ActionType_LIST_MESSAGES: LIST_MESSAGES, + gmproto.ActionType_SEND_MESSAGE: SEND_MESSAGE, + gmproto.ActionType_SEND_REACTION: SEND_REACTION, + gmproto.ActionType_DELETE_MESSAGE: DELETE_MESSAGE, + gmproto.ActionType_TYPING_UPDATES: TYPING_UPDATES, + gmproto.ActionType_GET_PARTICIPANTS_THUMBNAIL: GET_PARTICIPANT_THUMBNAIL, + gmproto.ActionType_LIST_CONTACTS: LIST_CONTACTS, + gmproto.ActionType_LIST_TOP_CONTACTS: LIST_TOP_CONTACTS, + gmproto.ActionType_GET_OR_CREATE_CONVERSATION: GET_OR_CREATE_CONVERSATION, } diff --git a/libgm/routes/messages.go b/libgm/routes/messages.go index 4be0a21..383f39c 100644 --- a/libgm/routes/messages.go +++ b/libgm/routes/messages.go @@ -1,47 +1,47 @@ package routes -import "go.mau.fi/mautrix-gmessages/libgm/binary" +import "go.mau.fi/mautrix-gmessages/libgm/gmproto" var LIST_MESSAGES = Route{ - Action: binary.ActionType_LIST_MESSAGES, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.FetchMessagesResponse{}, + Action: gmproto.ActionType_LIST_MESSAGES, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.FetchMessagesResponse{}, UseSessionID: false, UseTTL: true, } var SEND_MESSAGE = Route{ - Action: binary.ActionType_SEND_MESSAGE, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.SendMessageResponse{}, + Action: gmproto.ActionType_SEND_MESSAGE, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.SendMessageResponse{}, UseSessionID: false, UseTTL: true, } var SEND_REACTION = Route{ - Action: binary.ActionType_SEND_REACTION, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.SendReactionResponse{}, + Action: gmproto.ActionType_SEND_REACTION, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.SendReactionResponse{}, UseSessionID: false, UseTTL: true, } var DELETE_MESSAGE = Route{ - Action: binary.ActionType_DELETE_MESSAGE, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.DeleteMessageResponse{}, + Action: gmproto.ActionType_DELETE_MESSAGE, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.DeleteMessageResponse{}, UseSessionID: false, UseTTL: true, } var MESSAGE_READ = Route{ - Action: binary.ActionType_MESSAGE_READ, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, + Action: gmproto.ActionType_MESSAGE_READ, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, ResponseStruct: nil, UseSessionID: false, UseTTL: true, diff --git a/libgm/routes/session.go b/libgm/routes/session.go index 5a1f1a7..a75fe0b 100644 --- a/libgm/routes/session.go +++ b/libgm/routes/session.go @@ -1,57 +1,57 @@ package routes -import "go.mau.fi/mautrix-gmessages/libgm/binary" +import "go.mau.fi/mautrix-gmessages/libgm/gmproto" var IS_BUGLE_DEFAULT = Route{ - Action: binary.ActionType_IS_BUGLE_DEFAULT, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.IsBugleDefaultResponse{}, + Action: gmproto.ActionType_IS_BUGLE_DEFAULT, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.IsBugleDefaultResponse{}, UseSessionID: false, UseTTL: true, } var GET_UPDATES = Route{ - Action: binary.ActionType_GET_UPDATES, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.UpdateEvents{}, + Action: gmproto.ActionType_GET_UPDATES, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.UpdateEvents{}, UseSessionID: true, UseTTL: false, } var NOTIFY_DITTO_ACTIVITY = Route{ - Action: binary.ActionType_NOTIFY_DITTO_ACTIVITY, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, + Action: gmproto.ActionType_NOTIFY_DITTO_ACTIVITY, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, ResponseStruct: nil, UseSessionID: false, UseTTL: true, } var LIST_CONTACTS = Route{ - Action: binary.ActionType_LIST_CONTACTS, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.ListContactsResponse{}, + Action: gmproto.ActionType_LIST_CONTACTS, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.ListContactsResponse{}, UseSessionID: false, UseTTL: true, } var LIST_TOP_CONTACTS = Route{ - Action: binary.ActionType_LIST_TOP_CONTACTS, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.ListTopContactsResponse{}, + Action: gmproto.ActionType_LIST_TOP_CONTACTS, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.ListTopContactsResponse{}, UseSessionID: false, UseTTL: true, } var GET_OR_CREATE_CONVERSATION = Route{ - Action: binary.ActionType_GET_OR_CREATE_CONVERSATION, - MessageType: binary.MessageType_BUGLE_MESSAGE, - BugleRoute: binary.BugleRoute_DataEvent, - ResponseStruct: &binary.GetOrCreateConversationResponse{}, + Action: gmproto.ActionType_GET_OR_CREATE_CONVERSATION, + MessageType: gmproto.MessageType_BUGLE_MESSAGE, + BugleRoute: gmproto.BugleRoute_DataEvent, + ResponseStruct: &gmproto.GetOrCreateConversationResponse{}, UseSessionID: false, UseTTL: true, } diff --git a/libgm/rpc.go b/libgm/rpc.go index 9dd5fea..bee3a13 100644 --- a/libgm/rpc.go +++ b/libgm/rpc.go @@ -17,7 +17,7 @@ import ( "go.mau.fi/mautrix-gmessages/libgm/events" "go.mau.fi/mautrix-gmessages/libgm/pblite" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/util" ) @@ -47,14 +47,14 @@ func (r *RPC) ListenReceiveMessages() { return } r.client.Logger.Debug().Msg("Starting new long-polling request") - receivePayload, err := pblite.Marshal(&binary.ReceiveMessagesRequest{ - Auth: &binary.AuthMessage{ + receivePayload, err := pblite.Marshal(&gmproto.ReceiveMessagesRequest{ + Auth: &gmproto.AuthMessage{ RequestID: listenReqID, TachyonAuthToken: r.client.AuthData.TachyonAuthToken, ConfigVersion: util.ConfigMessage, }, - Unknown: &binary.ReceiveMessagesRequest_UnknownEmptyObject2{ - Unknown: &binary.ReceiveMessagesRequest_UnknownEmptyObject1{}, + Unknown: &gmproto.ReceiveMessagesRequest_UnknownEmptyObject2{ + Unknown: &gmproto.ReceiveMessagesRequest_UnknownEmptyObject1{}, }, }) if err != nil { @@ -160,7 +160,7 @@ func (r *RPC) startReadingData(rc io.ReadCloser) { } currentBlock := accumulatedData accumulatedData = accumulatedData[:0] - msg := &binary.InternalMessage{} + msg := &gmproto.InternalMessage{} err = pblite.Unmarshal(currentBlock, msg) if err != nil { r.client.Logger.Err(err).Msg("Error deserializing pblite message") diff --git a/libgm/session.go b/libgm/session.go index dc8c58e..3d56154 100644 --- a/libgm/session.go +++ b/libgm/session.go @@ -3,36 +3,36 @@ package libgm import ( "fmt" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) func (c *Client) SetActiveSession() error { c.sessionHandler.ResetSessionID() - actionType := binary.ActionType_GET_UPDATES + actionType := gmproto.ActionType_GET_UPDATES return c.sessionHandler.sendMessageNoResponse(actionType, nil) } -func (c *Client) IsBugleDefault() (*binary.IsBugleDefaultResponse, error) { +func (c *Client) IsBugleDefault() (*gmproto.IsBugleDefaultResponse, error) { c.sessionHandler.ResetSessionID() - actionType := binary.ActionType_IS_BUGLE_DEFAULT + actionType := gmproto.ActionType_IS_BUGLE_DEFAULT response, err := c.sessionHandler.sendMessage(actionType, nil) if err != nil { return nil, err } - res, ok := response.Data.Decrypted.(*binary.IsBugleDefaultResponse) + res, ok := response.Data.Decrypted.(*gmproto.IsBugleDefaultResponse) if !ok { - return nil, fmt.Errorf("unexpected response type %T, expected *binary.IsBugleDefaultResponse", response.Data.Decrypted) + return nil, fmt.Errorf("unexpected response type %T, expected *gmproto.IsBugleDefaultResponse", response.Data.Decrypted) } return res, nil } func (c *Client) NotifyDittoActivity() error { - payload := &binary.NotifyDittoActivityPayload{Success: true} - actionType := binary.ActionType_NOTIFY_DITTO_ACTIVITY + payload := &gmproto.NotifyDittoActivityPayload{Success: true} + actionType := gmproto.ActionType_NOTIFY_DITTO_ACTIVITY _, err := c.sessionHandler.sendMessage(actionType, payload) return err diff --git a/libgm/session_handler.go b/libgm/session_handler.go index 54d3d1b..2bfa6b4 100644 --- a/libgm/session_handler.go +++ b/libgm/session_handler.go @@ -11,7 +11,7 @@ import ( "go.mau.fi/mautrix-gmessages/libgm/pblite" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/payload" "go.mau.fi/mautrix-gmessages/libgm/routes" "go.mau.fi/mautrix-gmessages/libgm/util" @@ -36,7 +36,7 @@ func (s *SessionHandler) ResetSessionID() { s.sessionID = uuid.NewString() } -func (s *SessionHandler) sendMessageNoResponse(actionType binary.ActionType, encryptedData proto.Message) error { +func (s *SessionHandler) sendMessageNoResponse(actionType gmproto.ActionType, encryptedData proto.Message) error { _, payload, _, err := s.buildMessage(actionType, encryptedData) if err != nil { return err @@ -46,7 +46,7 @@ func (s *SessionHandler) sendMessageNoResponse(actionType binary.ActionType, enc return err } -func (s *SessionHandler) sendAsyncMessage(actionType binary.ActionType, encryptedData proto.Message) (<-chan *pblite.Response, error) { +func (s *SessionHandler) sendAsyncMessage(actionType gmproto.ActionType, encryptedData proto.Message) (<-chan *pblite.Response, error) { requestID, payload, _, buildErr := s.buildMessage(actionType, encryptedData) if buildErr != nil { return nil, buildErr @@ -61,7 +61,7 @@ func (s *SessionHandler) sendAsyncMessage(actionType binary.ActionType, encrypte return ch, nil } -func (s *SessionHandler) sendMessage(actionType binary.ActionType, encryptedData proto.Message) (*pblite.Response, error) { +func (s *SessionHandler) sendMessage(actionType gmproto.ActionType, encryptedData proto.Message) (*pblite.Response, error) { ch, err := s.sendAsyncMessage(actionType, encryptedData) if err != nil { return nil, err @@ -71,7 +71,7 @@ func (s *SessionHandler) sendMessage(actionType binary.ActionType, encryptedData return <-ch, nil } -func (s *SessionHandler) buildMessage(actionType binary.ActionType, encryptedData proto.Message) (string, []byte, binary.ActionType, error) { +func (s *SessionHandler) buildMessage(actionType gmproto.ActionType, encryptedData proto.Message) (string, []byte, gmproto.ActionType, error) { var requestID string pairedDevice := s.client.AuthData.Mobile sessionId := s.client.sessionHandler.sessionID @@ -138,20 +138,20 @@ func (s *SessionHandler) sendAckRequest() { if len(dataToAck) == 0 { return } - ackMessages := make([]*binary.AckMessageData, len(dataToAck)) + ackMessages := make([]*gmproto.AckMessageData, len(dataToAck)) for i, reqID := range dataToAck { - ackMessages[i] = &binary.AckMessageData{ + ackMessages[i] = &gmproto.AckMessageData{ RequestID: reqID, Device: s.client.AuthData.Browser, } } - ackMessagePayload := &binary.AckMessagePayload{ - AuthData: &binary.AuthMessage{ + ackMessagePayload := &gmproto.AckMessagePayload{ + AuthData: &gmproto.AuthMessage{ RequestID: uuid.NewString(), TachyonAuthToken: s.client.AuthData.TachyonAuthToken, ConfigVersion: util.ConfigMessage, }, - EmptyArr: &binary.EmptyArr{}, + EmptyArr: &gmproto.EmptyArr{}, Acks: ackMessages, } jsonData, err := pblite.Marshal(ackMessagePayload) diff --git a/libgm/updates_handler.go b/libgm/updates_handler.go index 5a705ce..c263668 100644 --- a/libgm/updates_handler.go +++ b/libgm/updates_handler.go @@ -4,40 +4,40 @@ import ( "go.mau.fi/mautrix-gmessages/libgm/events" "go.mau.fi/mautrix-gmessages/libgm/pblite" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) func (c *Client) handleUpdatesEvent(res *pblite.Response) { switch res.Data.Action { - case binary.ActionType_GET_UPDATES: - data, ok := res.Data.Decrypted.(*binary.UpdateEvents) + case gmproto.ActionType_GET_UPDATES: + data, ok := res.Data.Decrypted.(*gmproto.UpdateEvents) if !ok { c.Logger.Error().Type("data_type", res.Data.Decrypted).Msg("Unexpected data type in GET_UPDATES event") return } switch evt := data.Event.(type) { - case *binary.UpdateEvents_UserAlertEvent: + case *gmproto.UpdateEvents_UserAlertEvent: c.rpc.logContent(res) c.handleUserAlertEvent(res, evt.UserAlertEvent) - case *binary.UpdateEvents_SettingsEvent: + case *gmproto.UpdateEvents_SettingsEvent: c.rpc.logContent(res) c.triggerEvent(evt.SettingsEvent) - case *binary.UpdateEvents_ConversationEvent: + case *gmproto.UpdateEvents_ConversationEvent: if c.rpc.deduplicateUpdate(res) { return } c.triggerEvent(evt.ConversationEvent.GetData()) - case *binary.UpdateEvents_MessageEvent: + case *gmproto.UpdateEvents_MessageEvent: if c.rpc.deduplicateUpdate(res) { return } c.triggerEvent(evt.MessageEvent.GetData()) - case *binary.UpdateEvents_TypingEvent: + case *gmproto.UpdateEvents_TypingEvent: c.rpc.logContent(res) c.triggerEvent(evt.TypingEvent.GetData()) @@ -50,7 +50,7 @@ func (c *Client) handleUpdatesEvent(res *pblite.Response) { } func (c *Client) handleClientReady(newSessionId string) { - conversations, convErr := c.ListConversations(25, binary.ListConversationsPayload_INBOX) + conversations, convErr := c.ListConversations(25, gmproto.ListConversationsPayload_INBOX) if convErr != nil { panic(convErr) } @@ -62,10 +62,10 @@ func (c *Client) handleClientReady(newSessionId string) { c.triggerEvent(readyEvt) } -func (c *Client) handleUserAlertEvent(res *pblite.Response, data *binary.UserAlertEvent) { +func (c *Client) handleUserAlertEvent(res *pblite.Response, data *gmproto.UserAlertEvent) { alertType := data.AlertType switch alertType { - case binary.AlertType_BROWSER_ACTIVE: + case gmproto.AlertType_BROWSER_ACTIVE: newSessionID := res.Data.RequestID c.Logger.Debug().Any("session_id", newSessionID).Msg("Got browser active notification") if newSessionID != c.sessionHandler.sessionID { diff --git a/libgm/upload.go b/libgm/upload.go index 933c6a9..c138feb 100644 --- a/libgm/upload.go +++ b/libgm/upload.go @@ -12,70 +12,70 @@ import ( "github.com/google/uuid" "google.golang.org/protobuf/proto" - "go.mau.fi/mautrix-gmessages/libgm/binary" "go.mau.fi/mautrix-gmessages/libgm/crypto" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/util" ) type MediaType struct { Extension string Format string - Type binary.MediaFormats + Type gmproto.MediaFormats } var MimeToMediaType = map[string]MediaType{ - "image/jpeg": {Extension: "jpeg", Type: binary.MediaFormats_IMAGE_JPEG}, - "image/jpg": {Extension: "jpg", Type: binary.MediaFormats_IMAGE_JPG}, - "image/png": {Extension: "png", Type: binary.MediaFormats_IMAGE_PNG}, - "image/gif": {Extension: "gif", Type: binary.MediaFormats_IMAGE_GIF}, - "image/wbmp": {Extension: "wbmp", Type: binary.MediaFormats_IMAGE_WBMP}, - "image/bmp": {Extension: "bmp", Type: binary.MediaFormats_IMAGE_X_MS_BMP}, - "image/x-ms-bmp": {Extension: "bmp", Type: binary.MediaFormats_IMAGE_X_MS_BMP}, + "image/jpeg": {Extension: "jpeg", Type: gmproto.MediaFormats_IMAGE_JPEG}, + "image/jpg": {Extension: "jpg", Type: gmproto.MediaFormats_IMAGE_JPG}, + "image/png": {Extension: "png", Type: gmproto.MediaFormats_IMAGE_PNG}, + "image/gif": {Extension: "gif", Type: gmproto.MediaFormats_IMAGE_GIF}, + "image/wbmp": {Extension: "wbmp", Type: gmproto.MediaFormats_IMAGE_WBMP}, + "image/bmp": {Extension: "bmp", Type: gmproto.MediaFormats_IMAGE_X_MS_BMP}, + "image/x-ms-bmp": {Extension: "bmp", Type: gmproto.MediaFormats_IMAGE_X_MS_BMP}, - "video/mp4": {Extension: "mp4", Type: binary.MediaFormats_VIDEO_MP4}, - "video/3gpp2": {Extension: "3gpp2", Type: binary.MediaFormats_VIDEO_3G2}, - "video/3gpp": {Extension: "3gpp", Type: binary.MediaFormats_VIDEO_3GPP}, - "video/webm": {Extension: "webm", Type: binary.MediaFormats_VIDEO_WEBM}, - "video/x-matroska": {Extension: "mkv", Type: binary.MediaFormats_VIDEO_MKV}, + "video/mp4": {Extension: "mp4", Type: gmproto.MediaFormats_VIDEO_MP4}, + "video/3gpp2": {Extension: "3gpp2", Type: gmproto.MediaFormats_VIDEO_3G2}, + "video/3gpp": {Extension: "3gpp", Type: gmproto.MediaFormats_VIDEO_3GPP}, + "video/webm": {Extension: "webm", Type: gmproto.MediaFormats_VIDEO_WEBM}, + "video/x-matroska": {Extension: "mkv", Type: gmproto.MediaFormats_VIDEO_MKV}, - "audio/aac": {Extension: "aac", Type: binary.MediaFormats_AUDIO_AAC}, - "audio/amr": {Extension: "amr", Type: binary.MediaFormats_AUDIO_AMR}, - "audio/mp3": {Extension: "mp3", Type: binary.MediaFormats_AUDIO_MP3}, - "audio/mpeg": {Extension: "mpeg", Type: binary.MediaFormats_AUDIO_MPEG}, - "audio/mpg": {Extension: "mpg", Type: binary.MediaFormats_AUDIO_MPG}, - "audio/mp4": {Extension: "mp4", Type: binary.MediaFormats_AUDIO_MP4}, - "audio/mp4-latm": {Extension: "latm", Type: binary.MediaFormats_AUDIO_MP4_LATM}, - "audio/3gpp": {Extension: "3gpp", Type: binary.MediaFormats_AUDIO_3GPP}, - "audio/ogg": {Extension: "ogg", Type: binary.MediaFormats_AUDIO_OGG}, + "audio/aac": {Extension: "aac", Type: gmproto.MediaFormats_AUDIO_AAC}, + "audio/amr": {Extension: "amr", Type: gmproto.MediaFormats_AUDIO_AMR}, + "audio/mp3": {Extension: "mp3", Type: gmproto.MediaFormats_AUDIO_MP3}, + "audio/mpeg": {Extension: "mpeg", Type: gmproto.MediaFormats_AUDIO_MPEG}, + "audio/mpg": {Extension: "mpg", Type: gmproto.MediaFormats_AUDIO_MPG}, + "audio/mp4": {Extension: "mp4", Type: gmproto.MediaFormats_AUDIO_MP4}, + "audio/mp4-latm": {Extension: "latm", Type: gmproto.MediaFormats_AUDIO_MP4_LATM}, + "audio/3gpp": {Extension: "3gpp", Type: gmproto.MediaFormats_AUDIO_3GPP}, + "audio/ogg": {Extension: "ogg", Type: gmproto.MediaFormats_AUDIO_OGG}, - "text/vcard": {Extension: "vcard", Type: binary.MediaFormats_TEXT_VCARD}, - "application/pdf": {Extension: "pdf", Type: binary.MediaFormats_APP_PDF}, - "text/plain": {Extension: "txt", Type: binary.MediaFormats_APP_TXT}, - "text/html": {Extension: "html", Type: binary.MediaFormats_APP_HTML}, - "application/msword": {Extension: "doc", Type: binary.MediaFormats_APP_DOC}, - "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {Extension: "docx", Type: binary.MediaFormats_APP_DOCX}, - "application/vnd.openxmlformats-officedocument.presentationml.presentation": {Extension: "pptx", Type: binary.MediaFormats_APP_PPTX}, - "application/vnd.ms-powerpoint": {Extension: "ppt", Type: binary.MediaFormats_APP_PPT}, - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {Extension: "xlsx", Type: binary.MediaFormats_APP_XLSX}, - "application/vnd.ms-excel": {Extension: "xls", Type: binary.MediaFormats_APP_XLS}, - "application/vnd.android.package-archive": {Extension: "apk", Type: binary.MediaFormats_APP_APK}, - "application/zip": {Extension: "zip", Type: binary.MediaFormats_APP_ZIP}, - "application/java-archive": {Extension: "jar", Type: binary.MediaFormats_APP_JAR}, - "text/x-calendar": {Extension: "vcs", Type: binary.MediaFormats_CAL_TEXT_VCALENDAR}, - "text/calendar": {Extension: "ics", Type: binary.MediaFormats_CAL_TEXT_CALENDAR}, + "text/vcard": {Extension: "vcard", Type: gmproto.MediaFormats_TEXT_VCARD}, + "application/pdf": {Extension: "pdf", Type: gmproto.MediaFormats_APP_PDF}, + "text/plain": {Extension: "txt", Type: gmproto.MediaFormats_APP_TXT}, + "text/html": {Extension: "html", Type: gmproto.MediaFormats_APP_HTML}, + "application/msword": {Extension: "doc", Type: gmproto.MediaFormats_APP_DOC}, + "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {Extension: "docx", Type: gmproto.MediaFormats_APP_DOCX}, + "application/vnd.openxmlformats-officedocument.presentationml.presentation": {Extension: "pptx", Type: gmproto.MediaFormats_APP_PPTX}, + "application/vnd.ms-powerpoint": {Extension: "ppt", Type: gmproto.MediaFormats_APP_PPT}, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {Extension: "xlsx", Type: gmproto.MediaFormats_APP_XLSX}, + "application/vnd.ms-excel": {Extension: "xls", Type: gmproto.MediaFormats_APP_XLS}, + "application/vnd.android.package-archive": {Extension: "apk", Type: gmproto.MediaFormats_APP_APK}, + "application/zip": {Extension: "zip", Type: gmproto.MediaFormats_APP_ZIP}, + "application/java-archive": {Extension: "jar", Type: gmproto.MediaFormats_APP_JAR}, + "text/x-calendar": {Extension: "vcs", Type: gmproto.MediaFormats_CAL_TEXT_VCALENDAR}, + "text/calendar": {Extension: "ics", Type: gmproto.MediaFormats_CAL_TEXT_CALENDAR}, - "image": {Type: binary.MediaFormats_IMAGE_UNSPECIFIED}, - "video": {Type: binary.MediaFormats_VIDEO_UNSPECIFIED}, - "audio": {Type: binary.MediaFormats_AUDIO_UNSPECIFIED}, - "application": {Type: binary.MediaFormats_APP_UNSPECIFIED}, - "text": {Type: binary.MediaFormats_APP_TXT}, + "image": {Type: gmproto.MediaFormats_IMAGE_UNSPECIFIED}, + "video": {Type: gmproto.MediaFormats_VIDEO_UNSPECIFIED}, + "audio": {Type: gmproto.MediaFormats_AUDIO_UNSPECIFIED}, + "application": {Type: gmproto.MediaFormats_APP_UNSPECIFIED}, + "text": {Type: gmproto.MediaFormats_APP_TXT}, } -var FormatToMediaType = map[binary.MediaFormats]MediaType{ - binary.MediaFormats_CAL_TEXT_XVCALENDAR: MimeToMediaType["text/x-calendar"], - binary.MediaFormats_CAL_APPLICATION_VCS: MimeToMediaType["text/x-calendar"], - binary.MediaFormats_CAL_APPLICATION_ICS: MimeToMediaType["text/calendar"], - //binary.MediaFormats_CAL_APPLICATION_HBSVCS: ??? +var FormatToMediaType = map[gmproto.MediaFormats]MediaType{ + gmproto.MediaFormats_CAL_TEXT_XVCALENDAR: MimeToMediaType["text/x-calendar"], + gmproto.MediaFormats_CAL_APPLICATION_VCS: MimeToMediaType["text/x-calendar"], + gmproto.MediaFormats_CAL_APPLICATION_ICS: MimeToMediaType["text/calendar"], + //gmproto.MediaFormats_CAL_APPLICATION_HBSVCS: ??? } func init() { @@ -87,7 +87,7 @@ func init() { } } -func (c *Client) UploadMedia(data []byte, fileName, mime string) (*binary.MediaContent, error) { +func (c *Client) UploadMedia(data []byte, fileName, mime string) (*gmproto.MediaContent, error) { mediaType := MimeToMediaType[mime] if mediaType.Type == 0 { mediaType = MimeToMediaType[strings.Split(mime, "/")[0]] @@ -109,7 +109,7 @@ func (c *Client) UploadMedia(data []byte, fileName, mime string) (*binary.MediaC if err != nil { return nil, err } - return &binary.MediaContent{ + return &gmproto.MediaContent{ Format: mediaType.Type, MediaID: upload.MediaID, MediaName: fileName, @@ -171,7 +171,7 @@ func (c *Client) FinalizeUploadMedia(upload *StartGoogleUpload) (*MediaUpload, e uploadStatus := rHeaders.Get("x-goog-upload-status") c.Logger.Debug().Str("upload_status", uploadStatus).Msg("Upload complete") - mediaIDs := &binary.UploadMediaResponse{} + mediaIDs := &gmproto.UploadMediaResponse{} err3 = proto.Unmarshal(googleResponse, mediaIDs) if err3 != nil { return nil, err3 @@ -229,9 +229,9 @@ func (c *Client) StartUploadMedia(encryptedImageBytes []byte, mime string) (*Sta } func (c *Client) buildStartUploadPayload() (string, error) { - protoData := &binary.StartMediaUploadPayload{ + protoData := &gmproto.StartMediaUploadPayload{ ImageType: 1, - AuthData: &binary.AuthMessage{ + AuthData: &gmproto.AuthMessage{ RequestID: uuid.NewString(), TachyonAuthToken: c.AuthData.TachyonAuthToken, ConfigVersion: util.ConfigMessage, diff --git a/libgm/util/config.go b/libgm/util/config.go index efd640a..1d3942f 100644 --- a/libgm/util/config.go +++ b/libgm/util/config.go @@ -1,10 +1,10 @@ package util import ( - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) -var ConfigMessage = &binary.ConfigVersion{ +var ConfigMessage = &gmproto.ConfigVersion{ Year: 2023, Month: 7, Day: 10, @@ -12,9 +12,9 @@ var ConfigMessage = &binary.ConfigVersion{ V2: 6, } var Network = "Bugle" -var BrowserDetailsMessage = &binary.BrowserDetails{ +var BrowserDetailsMessage = &gmproto.BrowserDetails{ UserAgent: UserAgent, - BrowserType: binary.BrowserTypes_OTHER, + BrowserType: gmproto.BrowserTypes_OTHER, OS: "libgm", SomeBool: true, } diff --git a/libgm/util/func.go b/libgm/util/func.go index 8eaa853..0b98181 100644 --- a/libgm/util/func.go +++ b/libgm/util/func.go @@ -8,7 +8,7 @@ import ( "strconv" "time" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) func GenerateTmpID() string { @@ -91,7 +91,7 @@ func NewMediaUploadHeaders(imageSize string, command string, uploadOffset string return headers } -func ParseConfigVersion(res []byte) (*binary.ConfigVersion, error) { +func ParseConfigVersion(res []byte) (*gmproto.ConfigVersion, error) { var data []interface{} marshalErr := json.Unmarshal(res, &data) @@ -126,7 +126,7 @@ func ParseConfigVersion(res []byte) (*binary.ConfigVersion, error) { return nil, e2 } - configMessage := &binary.ConfigVersion{ + configMessage := &gmproto.ConfigVersion{ Year: int32(first), Month: int32(second), Day: int32(third), diff --git a/main.go b/main.go index 7a88b7a..a17a443 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,7 @@ import ( "go.mau.fi/mautrix-gmessages/config" "go.mau.fi/mautrix-gmessages/database" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/util" ) @@ -68,11 +68,11 @@ func (br *GMBridge) Init() { br.RegisterCommands() util.BrowserDetailsMessage.OS = br.Config.GoogleMessages.OS - browserVal, ok := binary.BrowserTypes_value[br.Config.GoogleMessages.Browser] + browserVal, ok := gmproto.BrowserTypes_value[br.Config.GoogleMessages.Browser] if !ok { br.ZLog.Error().Str("browser_value", br.Config.GoogleMessages.Browser).Msg("Invalid browser value") } else { - util.BrowserDetailsMessage.BrowserType = binary.BrowserTypes(browserVal) + util.BrowserDetailsMessage.BrowserType = gmproto.BrowserTypes(browserVal) } Segment.log = br.ZLog.With().Str("component", "segment").Logger() diff --git a/messagetracking.go b/messagetracking.go index 86f7d38..8fcd66c 100644 --- a/messagetracking.go +++ b/messagetracking.go @@ -31,7 +31,7 @@ import ( "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/id" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) var ( @@ -48,10 +48,10 @@ var ( errMessageTakingLong = errors.New("bridging the message is taking longer than usual") ) -type OutgoingStatusError binary.MessageStatusType +type OutgoingStatusError gmproto.MessageStatusType func (ose OutgoingStatusError) Error() string { - return strings.TrimPrefix(string((binary.MessageStatusType)(ose).Descriptor().Name()), "OUTGOING_") + return strings.TrimPrefix(string((gmproto.MessageStatusType)(ose).Descriptor().Name()), "OUTGOING_") } func (ose OutgoingStatusError) HumanError() string { diff --git a/portal.go b/portal.go index 47de5c1..9d61a6b 100644 --- a/portal.go +++ b/portal.go @@ -42,7 +42,7 @@ import ( "go.mau.fi/mautrix-gmessages/database" "go.mau.fi/mautrix-gmessages/libgm" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" "go.mau.fi/mautrix-gmessages/libgm/util" ) @@ -208,7 +208,7 @@ func (br *GMBridge) NewPortal(dbPortal *database.Portal) *Portal { const recentlyHandledLength = 100 type PortalMessage struct { - evt *binary.Message + evt *gmproto.Message source *User } @@ -313,7 +313,7 @@ func (portal *Portal) handleMessageLoop() { } } -func (portal *Portal) isOutgoingMessage(msg *binary.Message) id.EventID { +func (portal *Portal) isOutgoingMessage(msg *gmproto.Message) id.EventID { portal.outgoingMessagesLock.Lock() defer portal.outgoingMessagesLock.Unlock() out, ok := portal.outgoingMessages[msg.TmpID] @@ -327,18 +327,18 @@ func (portal *Portal) isOutgoingMessage(msg *binary.Message) id.EventID { out.Saved = true } switch msg.GetMessageStatus().GetStatus() { - case binary.MessageStatusType_OUTGOING_DELIVERED, binary.MessageStatusType_OUTGOING_COMPLETE, binary.MessageStatusType_OUTGOING_DISPLAYED: + case gmproto.MessageStatusType_OUTGOING_DELIVERED, gmproto.MessageStatusType_OUTGOING_COMPLETE, gmproto.MessageStatusType_OUTGOING_DISPLAYED: delete(portal.outgoingMessages, msg.TmpID) go portal.sendStatusEvent(out.ID, "", nil) - case binary.MessageStatusType_OUTGOING_FAILED_GENERIC, - binary.MessageStatusType_OUTGOING_FAILED_EMERGENCY_NUMBER, - binary.MessageStatusType_OUTGOING_CANCELED, - binary.MessageStatusType_OUTGOING_FAILED_TOO_LARGE, - binary.MessageStatusType_OUTGOING_FAILED_RECIPIENT_LOST_RCS, - binary.MessageStatusType_OUTGOING_FAILED_NO_RETRY_NO_FALLBACK, - binary.MessageStatusType_OUTGOING_FAILED_RECIPIENT_DID_NOT_DECRYPT, - binary.MessageStatusType_OUTGOING_FAILED_RECIPIENT_LOST_ENCRYPTION, - binary.MessageStatusType_OUTGOING_FAILED_RECIPIENT_DID_NOT_DECRYPT_NO_MORE_RETRY: + case gmproto.MessageStatusType_OUTGOING_FAILED_GENERIC, + gmproto.MessageStatusType_OUTGOING_FAILED_EMERGENCY_NUMBER, + gmproto.MessageStatusType_OUTGOING_CANCELED, + gmproto.MessageStatusType_OUTGOING_FAILED_TOO_LARGE, + gmproto.MessageStatusType_OUTGOING_FAILED_RECIPIENT_LOST_RCS, + gmproto.MessageStatusType_OUTGOING_FAILED_NO_RETRY_NO_FALLBACK, + gmproto.MessageStatusType_OUTGOING_FAILED_RECIPIENT_DID_NOT_DECRYPT, + gmproto.MessageStatusType_OUTGOING_FAILED_RECIPIENT_LOST_ENCRYPTION, + gmproto.MessageStatusType_OUTGOING_FAILED_RECIPIENT_DID_NOT_DECRYPT_NO_MORE_RETRY: err := OutgoingStatusError(msg.GetMessageStatus().GetStatus()) go portal.sendStatusEvent(out.ID, "", err) // TODO error notice @@ -347,9 +347,9 @@ func (portal *Portal) isOutgoingMessage(msg *binary.Message) id.EventID { } return "" } -func hasInProgressMedia(msg *binary.Message) bool { +func hasInProgressMedia(msg *gmproto.Message) bool { for _, part := range msg.MessageInfo { - media, ok := part.GetData().(*binary.MessageInfo_MediaContent) + media, ok := part.GetData().(*gmproto.MessageInfo_MediaContent) if ok && media.MediaContent.GetMediaID() == "" { return true } @@ -357,7 +357,7 @@ func hasInProgressMedia(msg *binary.Message) bool { return false } -func (portal *Portal) handleMessage(source *User, evt *binary.Message) { +func (portal *Portal) handleMessage(source *User, evt *gmproto.Message) { if len(portal.MXID) == 0 { portal.zlog.Warn().Msg("handleMessage called even though portal.MXID is empty") return @@ -374,10 +374,10 @@ func (portal *Portal) handleMessage(source *User, evt *binary.Message) { Logger() ctx := log.WithContext(context.TODO()) switch evt.GetMessageStatus().GetStatus() { - case binary.MessageStatusType_INCOMING_AUTO_DOWNLOADING, binary.MessageStatusType_INCOMING_RETRYING_AUTO_DOWNLOAD: + case gmproto.MessageStatusType_INCOMING_AUTO_DOWNLOADING, gmproto.MessageStatusType_INCOMING_RETRYING_AUTO_DOWNLOAD: log.Debug().Msg("Not handling incoming message that is auto downloading") return - case binary.MessageStatusType_MESSAGE_DELETED: + case gmproto.MessageStatusType_MESSAGE_DELETED: portal.handleGoogleDeletion(ctx, evt.MessageID) return } @@ -435,7 +435,7 @@ func (portal *Portal) handleGoogleDeletion(ctx context.Context, messageID string } } -func (portal *Portal) syncReactions(ctx context.Context, source *User, message *database.Message, reactions []*binary.ReactionResponse) { +func (portal *Portal) syncReactions(ctx context.Context, source *User, message *database.Message, reactions []*gmproto.ReactionResponse) { log := zerolog.Ctx(ctx) existing, err := portal.bridge.DB.Reaction.GetAllByMessage(ctx, portal.Key, message.ID) if err != nil { @@ -535,7 +535,7 @@ func (portal *Portal) getIntent(ctx context.Context, source *User, participant s } } -func (portal *Portal) convertGoogleMessage(ctx context.Context, source *User, evt *binary.Message, backfill bool) *ConvertedMessage { +func (portal *Portal) convertGoogleMessage(ctx context.Context, source *User, evt *gmproto.Message, backfill bool) *ConvertedMessage { log := zerolog.Ctx(ctx) var cm ConvertedMessage @@ -568,7 +568,7 @@ func (portal *Portal) convertGoogleMessage(ctx context.Context, source *User, ev for _, part := range evt.MessageInfo { var content event.MessageEventContent switch data := part.GetData().(type) { - case *binary.MessageInfo_MessageContent: + case *gmproto.MessageInfo_MessageContent: content = event.MessageEventContent{ MsgType: event.MsgText, Body: data.MessageContent.GetContent(), @@ -579,7 +579,7 @@ func (portal *Portal) convertGoogleMessage(ctx context.Context, source *User, ev content.Body = fmt.Sprintf("**%s**\n%s", subject, content.Body) subject = "" } - case *binary.MessageInfo_MediaContent: + case *gmproto.MessageInfo_MediaContent: contentPtr, err := portal.convertGoogleMedia(source, cm.Intent, data.MediaContent) if err != nil { log.Err(err).Msg("Failed to copy attachment") @@ -642,7 +642,7 @@ func (msg *ConvertedMessage) MergeCaption() { msg.Parts = []ConvertedMessagePart{filePart} } -func (portal *Portal) convertGoogleMedia(source *User, intent *appservice.IntentAPI, msg *binary.MediaContent) (*event.MessageEventContent, error) { +func (portal *Portal) convertGoogleMedia(source *User, intent *appservice.IntentAPI, msg *gmproto.MediaContent) (*event.MessageEventContent, error) { var data []byte var err error data, err = source.Client.DownloadMedia(msg.MediaID, msg.DecryptionKey) @@ -707,8 +707,8 @@ func (portal *Portal) markHandled(cm *ConvertedMessage, eventID id.EventID, rece return msg } -func (portal *Portal) SyncParticipants(source *User, metadata *binary.Conversation) (userIDs []id.UserID, changed bool) { - var firstParticipant *binary.Participant +func (portal *Portal) SyncParticipants(source *User, metadata *gmproto.Conversation) (userIDs []id.UserID, changed bool) { + var firstParticipant *gmproto.Participant var manyParticipants bool for _, participant := range metadata.Participants { if participant.IsMe { @@ -782,7 +782,7 @@ func (portal *Portal) UpdateName(name string, updateInfo bool) bool { return false } -func (portal *Portal) UpdateMetadata(user *User, info *binary.Conversation) []id.UserID { +func (portal *Portal) UpdateMetadata(user *User, info *gmproto.Conversation) []id.UserID { participants, update := portal.SyncParticipants(user, info) if portal.SelfUserID != info.SelfParticipantID { portal.SelfUserID = info.SelfParticipantID @@ -811,7 +811,7 @@ func (portal *Portal) ensureUserInvited(user *User) bool { return user.ensureInvited(portal.MainIntent(), portal.MXID, portal.IsPrivateChat()) } -func (portal *Portal) UpdateMatrixRoom(user *User, groupInfo *binary.Conversation) bool { +func (portal *Portal) UpdateMatrixRoom(user *User, groupInfo *gmproto.Conversation) bool { if len(portal.MXID) == 0 { return false } @@ -899,7 +899,7 @@ func (portal *Portal) GetEncryptionEventContent() (evt *event.EncryptionEventCon return } -func (portal *Portal) CreateMatrixRoom(user *User, conv *binary.Conversation) error { +func (portal *Portal) CreateMatrixRoom(user *User, conv *gmproto.Conversation) error { portal.roomCreateLock.Lock() defer portal.roomCreateLock.Unlock() if len(portal.MXID) > 0 { @@ -1172,12 +1172,12 @@ func (portal *Portal) uploadMedia(intent *appservice.IntentAPI, data []byte, con return nil } -func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, content *event.MessageEventContent, txnID string) (*binary.SendMessagePayload, error) { +func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, content *event.MessageEventContent, txnID string) (*gmproto.SendMessagePayload, error) { log := zerolog.Ctx(ctx) - req := &binary.SendMessagePayload{ + req := &gmproto.SendMessagePayload{ ConversationID: portal.ID, TmpID: txnID, - MessagePayload: &binary.MessagePayload{ + MessagePayload: &gmproto.MessagePayload{ ConversationID: portal.ID, TmpID: txnID, TmpID2: txnID, @@ -1194,7 +1194,7 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, co log.Warn().Str("reply_to_mxid", replyToMXID.String()).Msg("Reply target message not found") } else { req.IsReply = true - req.Reply = &binary.ReplyPayload{MessageID: replyToMsg.ID} + req.Reply = &gmproto.ReplyPayload{MessageID: replyToMsg.ID} } } @@ -1204,8 +1204,8 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, co if content.MsgType == event.MsgEmote { text = "/me " + text } - req.MessagePayload.MessageInfo = []*binary.MessageInfo{{ - Data: &binary.MessageInfo_MessageContent{MessageContent: &binary.MessageContent{ + req.MessagePayload.MessageInfo = []*gmproto.MessageInfo{{ + Data: &gmproto.MessageInfo_MessageContent{MessageContent: &gmproto.MessageContent{ Content: text, }}, }} @@ -1240,8 +1240,8 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, co if err != nil { return nil, mutil.NewDualError(errMediaReuploadFailed, err) } - req.MessagePayload.MessageInfo = []*binary.MessageInfo{{ - Data: &binary.MessageInfo_MediaContent{MediaContent: resp}, + req.MessagePayload.MessageInfo = []*gmproto.MessageInfo{{ + Data: &gmproto.MessageInfo_MediaContent{MediaContent: resp}, }} default: return nil, fmt.Errorf("%w %s", errUnknownMsgType, content.MsgType) @@ -1349,13 +1349,13 @@ func (portal *Portal) handleMatrixReaction(sender *User, evt *event.Event) error } emoji := variationselector.Remove(content.RelatesTo.Key) - action := binary.Reaction_ADD + action := gmproto.Reaction_ADD if existingReaction != nil { - action = binary.Reaction_SWITCH + action = gmproto.Reaction_SWITCH } - resp, err := sender.Client.SendReaction(&binary.SendReactionPayload{ + resp, err := sender.Client.SendReaction(&gmproto.SendReactionPayload{ MessageID: msg.ID, - ReactionData: binary.MakeReactionData(emoji), + ReactionData: gmproto.MakeReactionData(emoji), Action: action, }) if err != nil { @@ -1425,10 +1425,10 @@ func (portal *Portal) handleMatrixReactionRedaction(ctx context.Context, sender return errTargetNotFound } - resp, err := sender.Client.SendReaction(&binary.SendReactionPayload{ + resp, err := sender.Client.SendReaction(&gmproto.SendReactionPayload{ MessageID: existingReaction.MessageID, - ReactionData: binary.MakeReactionData(existingReaction.Reaction), - Action: binary.Reaction_REMOVE, + ReactionData: gmproto.MakeReactionData(existingReaction.Reaction), + Action: gmproto.Reaction_REMOVE, }) if err != nil { return fmt.Errorf("failed to send reaction removal: %w", err) diff --git a/provisioning.go b/provisioning.go index b5f6687..99ee6d8 100644 --- a/provisioning.go +++ b/provisioning.go @@ -32,7 +32,7 @@ import ( "maunium.net/go/mautrix/bridge/status" "maunium.net/go/mautrix/id" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) type ProvisioningAPI struct { @@ -195,10 +195,10 @@ func (prov *ProvisioningAPI) StartChat(w http.ResponseWriter, r *http.Request) { ErrCode: "bad json", }) } - var reqData binary.GetOrCreateConversationPayload - reqData.Numbers = make([]*binary.ContactNumber, 0, len(req.Numbers)) + var reqData gmproto.GetOrCreateConversationPayload + reqData.Numbers = make([]*gmproto.ContactNumber, 0, len(req.Numbers)) for _, number := range req.Numbers { - reqData.Numbers = append(reqData.Numbers, &binary.ContactNumber{ + reqData.Numbers = append(reqData.Numbers, &gmproto.ContactNumber{ // This should maybe sometimes be 7 MysteriousInt: 2, Number: number, @@ -213,7 +213,7 @@ func (prov *ProvisioningAPI) StartChat(w http.ResponseWriter, r *http.Request) { ErrCode: "unknown error", }) return - } else if resp.GetStatus() == binary.GetOrCreateConversationResponse_CREATE_RCS { + } else if resp.GetStatus() == gmproto.GetOrCreateConversationResponse_CREATE_RCS { prov.zlog.Debug().Msg("Creating RCS group") // TODO this will always create a new group and won't deduplicate reqData.CreateRCSGroup = proto.Bool(true) diff --git a/puppet.go b/puppet.go index 1db496e..134afb5 100644 --- a/puppet.go +++ b/puppet.go @@ -29,7 +29,7 @@ import ( "maunium.net/go/mautrix/id" "go.mau.fi/mautrix-gmessages/database" - "go.mau.fi/mautrix-gmessages/libgm/binary" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) var userIDRegex *regexp.Regexp @@ -253,7 +253,7 @@ func (puppet *Puppet) updatePortalName() { // TODO implement } -func (puppet *Puppet) Sync(source *User, contact *binary.Participant) { +func (puppet *Puppet) Sync(source *User, contact *gmproto.Participant) { err := puppet.DefaultIntent().EnsureRegistered() if err != nil { puppet.log.Err(err).Msg("Failed to ensure registered") diff --git a/user.go b/user.go index 8895085..ccf238f 100644 --- a/user.go +++ b/user.go @@ -42,8 +42,8 @@ import ( "go.mau.fi/mautrix-gmessages/database" "go.mau.fi/mautrix-gmessages/libgm" - "go.mau.fi/mautrix-gmessages/libgm/binary" "go.mau.fi/mautrix-gmessages/libgm/events" + "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) type User struct { @@ -602,7 +602,7 @@ func (user *User) HandleEvent(event interface{}) { if ch := user.pairSuccessChan; ch != nil { close(ch) } - case *binary.RevokePairData: + case *gmproto.RevokePairData: user.zlog.Info().Any("revoked_device", v.GetRevokedDevice()).Msg("Got pair revoked event") user.Logout(status.BridgeState{ StateEvent: status.StateBadCredentials, @@ -613,9 +613,9 @@ func (user *User) HandleEvent(event interface{}) { if err != nil { user.zlog.Err(err).Msg("Failed to update session in database") } - case *binary.Conversation: + case *gmproto.Conversation: user.syncConversation(v) - case *binary.Message: + case *gmproto.Message: portal := user.GetPortalByID(v.GetConversationID()) portal.messages <- PortalMessage{evt: v, source: user} case *events.ClientReady: @@ -629,30 +629,30 @@ func (user *User) HandleEvent(event interface{}) { case *events.BrowserActive: user.zlog.Trace().Any("data", v).Msg("Browser active") user.browserInactiveType = "" - case *binary.UserAlertEvent: + case *gmproto.UserAlertEvent: user.handleUserAlert(v) default: user.zlog.Trace().Any("data", v).Type("data_type", v).Msg("Unknown event") } } -func (user *User) handleUserAlert(v *binary.UserAlertEvent) { +func (user *User) handleUserAlert(v *gmproto.UserAlertEvent) { user.zlog.Debug().Any("data", v).Msg("Got user alert event") switch v.GetAlertType() { - case binary.AlertType_BROWSER_INACTIVE: + case gmproto.AlertType_BROWSER_INACTIVE: // TODO aggressively reactivate if configured to do so user.browserInactiveType = GMBrowserInactive - case binary.AlertType_BROWSER_INACTIVE_FROM_TIMEOUT: + case gmproto.AlertType_BROWSER_INACTIVE_FROM_TIMEOUT: user.browserInactiveType = GMBrowserInactiveTimeout - case binary.AlertType_BROWSER_INACTIVE_FROM_INACTIVITY: + case gmproto.AlertType_BROWSER_INACTIVE_FROM_INACTIVITY: user.browserInactiveType = GMBrowserInactiveInactivity - case binary.AlertType_MOBILE_DATA_CONNECTION: + case gmproto.AlertType_MOBILE_DATA_CONNECTION: user.mobileData = true - case binary.AlertType_MOBILE_WIFI_CONNECTION: + case gmproto.AlertType_MOBILE_WIFI_CONNECTION: user.mobileData = false - case binary.AlertType_MOBILE_BATTERY_LOW: + case gmproto.AlertType_MOBILE_BATTERY_LOW: user.batteryLow = true - case binary.AlertType_MOBILE_BATTERY_RESTORED: + case gmproto.AlertType_MOBILE_BATTERY_RESTORED: user.batteryLow = false default: return @@ -696,13 +696,13 @@ func (user *User) Logout(state status.BridgeState, unpair bool) (logoutOK bool) return } -func (user *User) syncConversation(v *binary.Conversation) { +func (user *User) syncConversation(v *gmproto.Conversation) { updateType := v.GetStatus() portal := user.GetPortalByID(v.GetConversationID()) if portal.MXID != "" { switch updateType { // TODO also delete if blocked? - case binary.ConvUpdateTypes_DELETED: + case gmproto.ConvUpdateTypes_DELETED: user.zlog.Info().Str("conversation_id", portal.ID).Msg("Got delete event, cleaning up portal") portal.Delete() portal.Cleanup(false) @@ -711,7 +711,7 @@ func (user *User) syncConversation(v *binary.Conversation) { portal.missedForwardBackfill(user, time.UnixMicro(v.LastMessageTimestamp), v.LatestMessageID, !v.GetUnread()) // TODO sync read status if there was nothing backfilled } - } else if updateType == binary.ConvUpdateTypes_UNARCHIVED || updateType == binary.ConvUpdateTypes_ARCHIVED { + } else if updateType == gmproto.ConvUpdateTypes_UNARCHIVED || updateType == gmproto.ConvUpdateTypes_ARCHIVED { err := portal.CreateMatrixRoom(user, v) if err != nil { user.zlog.Err(err).Msg("Error creating Matrix room from conversation event") @@ -787,7 +787,7 @@ type CustomReadMarkers struct { FullyReadExtra CustomReadReceipt `json:"com.beeper.fully_read.extra"` } -func (user *User) syncChatDoublePuppetDetails(portal *Portal, conv *binary.Conversation, justCreated bool) { +func (user *User) syncChatDoublePuppetDetails(portal *Portal, conv *gmproto.Conversation, justCreated bool) { if user.DoublePuppetIntent == nil || len(portal.MXID) == 0 { return }