gmessages/libgm/payload/registerRefresh.go
Tulir Asokan 1615e146b6 Update library
Co-authored-by: zero <108243503+0xzer@users.noreply.github.com>
2023-07-09 14:49:55 +03:00

35 lines
926 B
Go

package payload
import (
"encoding/json"
"go.mau.fi/mautrix-gmessages/libgm/binary"
"go.mau.fi/mautrix-gmessages/libgm/pblite"
)
func RegisterRefresh(sig string, requestId string, timestamp int64, browser *binary.Device, tachyonAuthToken []byte) ([]byte, error) {
payload := &binary.RegisterRefreshPayload{
MessageAuth: &binary.AuthMessage{
RequestID: requestId,
TachyonAuthToken: tachyonAuthToken,
ConfigVersion: ConfigMessage,
},
CurrBrowserDevice: browser,
UnixTimestamp: timestamp,
Signature: sig,
EmptyRefreshArr: &binary.EmptyRefreshArr{EmptyArr: &binary.EmptyEmptyArr{}},
MessageType: 2, // hmm
}
serialized, serializeErr := pblite.Serialize(payload.ProtoReflect())
if serializeErr != nil {
return nil, serializeErr
}
jsonMessage, marshalErr := json.Marshal(serialized)
if marshalErr != nil {
return nil, marshalErr
}
return jsonMessage, nil
}