gmessages/libgm/payload/receiveMessages.go

39 lines
818 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{
2023-06-30 13:26:46 +00:00
RequestID: uuid.New().String(),
RpcKey: rpcKey,
Date: &binary.Date{
Year: 2023,
Seq1: 6,
2023-07-02 14:19:00 +00:00
Seq2: 22,
Seq3: 4,
Seq4: 6,
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
}