2023-06-30 09:54:08 +00:00
|
|
|
package payload
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
2023-06-30 12:49:32 +00:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
2023-06-30 12:49:32 +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(),
|
2023-06-30 12:49:32 +00:00
|
|
|
RpcKey: rpcKey,
|
|
|
|
Date: &binary.Date{
|
|
|
|
Year: 2023,
|
|
|
|
Seq1: 6,
|
2023-07-02 14:19:00 +00:00
|
|
|
Seq2: 22,
|
2023-06-30 12:49:32 +00:00
|
|
|
Seq3: 4,
|
|
|
|
Seq4: 6,
|
2023-06-30 09:54:08 +00:00
|
|
|
},
|
|
|
|
},
|
2023-06-30 12:49:32 +00:00
|
|
|
Unknown: &binary.ReceiveMessagesRequest_UnknownEmptyObject2{
|
|
|
|
Unknown: &binary.ReceiveMessagesRequest_UnknownEmptyObject1{},
|
2023-06-30 09:54:08 +00:00
|
|
|
},
|
|
|
|
}
|
2023-06-30 12:49:32 +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
|
|
|
}
|