gmessages/libgm/payload/receiveMessages.go

33 lines
770 B
Go
Raw Normal View History

2023-06-30 09:54:08 +00:00
package payload
import (
"encoding/json"
"github.com/google/uuid"
"go.mau.fi/mautrix-gmessages/libgm/binary"
"go.mau.fi/mautrix-gmessages/libgm/pblite"
2023-06-30 09:54:08 +00:00
)
func ReceiveMessages(rpcKey []byte) ([]byte, string, error) {
payload := &binary.ReceiveMessagesRequest{
Auth: &binary.AuthMessage{
RequestID: uuid.New().String(),
TachyonAuthToken: rpcKey,
ConfigVersion: ConfigMessage,
2023-06-30 09:54:08 +00:00
},
Unknown: &binary.ReceiveMessagesRequest_UnknownEmptyObject2{
Unknown: &binary.ReceiveMessagesRequest_UnknownEmptyObject1{},
2023-06-30 09:54:08 +00:00
},
}
data, err := pblite.Serialize(payload.ProtoReflect())
if err != nil {
return nil, "", err
}
2023-06-30 09:54:08 +00:00
jsonData, err := json.Marshal(data)
if err != nil {
return nil, "", err
}
2023-06-30 13:26:46 +00:00
return jsonData, payload.Auth.RequestID, nil
2023-06-30 09:54:08 +00:00
}