Fix URL constant names

This commit is contained in:
Tulir Asokan 2023-07-16 02:21:53 +03:00
parent 15fbc4b654
commit 8302bc95ee
6 changed files with 30 additions and 30 deletions

View file

@ -212,7 +212,7 @@ func (c *Client) DownloadMedia(mediaID string, key []byte) ([]byte, error) {
return nil, err2 return nil, err2
} }
downloadMetadataEncoded := base64.StdEncoding.EncodeToString(downloadMetadataBytes) downloadMetadataEncoded := base64.StdEncoding.EncodeToString(downloadMetadataBytes)
req, err := http.NewRequest("GET", util.UPLOAD_MEDIA, nil) req, err := http.NewRequest("GET", util.UploadMediaURL, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -221,7 +221,7 @@ func (c *Client) DownloadMedia(mediaID string, key []byte) ([]byte, error) {
if reqErr != nil { if reqErr != nil {
return nil, reqErr return nil, reqErr
} }
c.Logger.Info().Any("url", util.UPLOAD_MEDIA).Any("headers", res.Request.Header).Msg("Decrypt Image Headers") c.Logger.Info().Any("url", util.UploadMediaURL).Any("headers", res.Request.Header).Msg("Decrypt Image Headers")
defer res.Body.Close() defer res.Body.Close()
encryptedBuffImg, err3 := io.ReadAll(res.Body) encryptedBuffImg, err3 := io.ReadAll(res.Body)
if err3 != nil { if err3 != nil {
@ -240,7 +240,7 @@ func (c *Client) DownloadMedia(mediaID string, key []byte) ([]byte, error) {
} }
func (c *Client) FetchConfigVersion() { func (c *Client) FetchConfigVersion() {
req, bErr := http.NewRequest("GET", util.CONFIG_URL, nil) req, bErr := http.NewRequest("GET", util.ConfigUrl, nil)
if bErr != nil { if bErr != nil {
panic(bErr) panic(bErr)
} }
@ -345,7 +345,7 @@ func (c *Client) refreshAuthToken() error {
c.Logger.Info().Any("payload", string(payloadMessage)).Msg("Attempting to refresh auth token") c.Logger.Info().Any("payload", string(payloadMessage)).Msg("Attempting to refresh auth token")
refreshResponse, requestErr := c.rpc.sendMessageRequest(util.REGISTER_REFRESH, payloadMessage) refreshResponse, requestErr := c.rpc.sendMessageRequest(util.RegisterRefreshURL, payloadMessage)
if requestErr != nil { if requestErr != nil {
return requestErr return requestErr
} }

View file

@ -88,7 +88,7 @@ func (c *Client) StartUploadMedia(encryptedImageBytes []byte, mime string) (*Sta
return nil, buildPayloadErr return nil, buildPayloadErr
} }
req, reqErr := http.NewRequest("POST", util.UPLOAD_MEDIA, bytes.NewBuffer([]byte(startUploadPayload))) req, reqErr := http.NewRequest("POST", util.UploadMediaURL, bytes.NewBuffer([]byte(startUploadPayload)))
if reqErr != nil { if reqErr != nil {
return nil, reqErr return nil, reqErr
} }

View file

@ -50,7 +50,7 @@ func (p *Pairer) RegisterPhoneRelay() (*binary.RegisterPhoneRelayResponse, error
p.client.Logger.Err(err) p.client.Logger.Err(err)
return &binary.RegisterPhoneRelayResponse{}, err return &binary.RegisterPhoneRelayResponse{}, err
} }
relayResponse, reqErr := p.client.MakeRelayRequest(util.REGISTER_PHONE_RELAY, body) relayResponse, reqErr := p.client.MakeRelayRequest(util.RegisterPhoneRelayURL, body)
if reqErr != nil { if reqErr != nil {
p.client.Logger.Err(reqErr) p.client.Logger.Err(reqErr)
return nil, err return nil, err
@ -102,7 +102,7 @@ func (p *Pairer) RefreshPhoneRelay() {
p.client.Logger.Err(err).Msg("refresh phone relay err") p.client.Logger.Err(err).Msg("refresh phone relay err")
return return
} }
relayResponse, reqErr := p.client.MakeRelayRequest(util.REFRESH_PHONE_RELAY, body) relayResponse, reqErr := p.client.MakeRelayRequest(util.RefreshPhoneRelayURL, body)
if reqErr != nil { if reqErr != nil {
p.client.Logger.Err(reqErr).Msg("refresh phone relay err") p.client.Logger.Err(reqErr).Msg("refresh phone relay err")
} }
@ -137,7 +137,7 @@ func (c *Client) GetWebEncryptionKey() (*binary.WebEncryptionKeyResponse, error)
if err != nil { if err != nil {
return nil, err return nil, err
} }
webKeyResponse, err := c.MakeRelayRequest(util.GET_WEB_ENCRYPTION_KEY, body) webKeyResponse, err := c.MakeRelayRequest(util.GetWebEncryptionKeyURL, body)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -174,7 +174,7 @@ func (c *Client) Unpair() (*binary.RevokeRelayPairingResponse, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
revokeResp, err := c.MakeRelayRequest(util.REVOKE_RELAY_PAIRING, payload) revokeResp, err := c.MakeRelayRequest(util.RevokeRelayPairingURL, payload)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -49,7 +49,7 @@ func (r *RPC) ListenReceiveMessages(payload []byte) {
} }
} }
r.client.Logger.Debug().Msg("Starting new long-polling request") r.client.Logger.Debug().Msg("Starting new long-polling request")
req, err := http.NewRequest("POST", util.RECEIVE_MESSAGES, bytes.NewReader(payload)) req, err := http.NewRequest("POST", util.ReceiveMessagesURL, bytes.NewReader(payload))
if err != nil { if err != nil {
panic(fmt.Errorf("Error creating request: %v", err)) panic(fmt.Errorf("Error creating request: %v", err))
} }

View file

@ -41,7 +41,7 @@ func (s *SessionHandler) sendMessageNoResponse(actionType binary.ActionType, enc
return err return err
} }
_, err = s.client.rpc.sendMessageRequest(util.SEND_MESSAGE, payload) _, err = s.client.rpc.sendMessageRequest(util.SendMessageURL, payload)
return err return err
} }
@ -52,7 +52,7 @@ func (s *SessionHandler) sendAsyncMessage(actionType binary.ActionType, encrypte
} }
ch := s.waitResponse(requestID) ch := s.waitResponse(requestID)
_, reqErr := s.client.rpc.sendMessageRequest(util.SEND_MESSAGE, payload) _, reqErr := s.client.rpc.sendMessageRequest(util.SendMessageURL, payload)
if reqErr != nil { if reqErr != nil {
s.cancelResponse(requestID, ch) s.cancelResponse(requestID, ch)
return nil, reqErr return nil, reqErr
@ -157,7 +157,7 @@ func (s *SessionHandler) sendAckRequest() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
_, err = s.client.rpc.sendMessageRequest(util.ACK_MESSAGES, jsonData) _, err = s.client.rpc.sendMessageRequest(util.AckMessagesURL, jsonData)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View file

@ -1,26 +1,26 @@
package util package util
var MESSAGES_GOOGLE_BASE_URL = "https://messages.google.com" const messagesBaseURL = "https://messages.google.com"
var MESSAGES_GOOGLE_AUTHENTICATION = MESSAGES_GOOGLE_BASE_URL + "/web/authentication" const GoogleAuthenticationURL = messagesBaseURL + "/web/authentication"
var MESSAGES_GOOGLE_TIMESOURCE = MESSAGES_GOOGLE_BASE_URL + "/web/timesource" const GoogleTimesourceURL = messagesBaseURL + "/web/timesource"
var INSTANT_MESSAGING = "https://instantmessaging-pa.googleapis.com" const instantMessangingBaseURL = "https://instantmessaging-pa.googleapis.com"
var UPLOAD_MEDIA = INSTANT_MESSAGING + "/upload" const UploadMediaURL = instantMessangingBaseURL + "/upload"
var PAIRING = INSTANT_MESSAGING + "/$rpc/google.internal.communications.instantmessaging.v1.Pairing" const pairingBaseURL = instantMessangingBaseURL + "/$rpc/google.internal.communications.instantmessaging.v1.Pairing"
var REGISTER_PHONE_RELAY = PAIRING + "/RegisterPhoneRelay" const RegisterPhoneRelayURL = pairingBaseURL + "/RegisterPhoneRelay"
var REFRESH_PHONE_RELAY = PAIRING + "/RefreshPhoneRelay" const RefreshPhoneRelayURL = pairingBaseURL + "/RefreshPhoneRelay"
var GET_WEB_ENCRYPTION_KEY = PAIRING + "/GetWebEncryptionKey" const GetWebEncryptionKeyURL = pairingBaseURL + "/GetWebEncryptionKey"
var REVOKE_RELAY_PAIRING = PAIRING + "/RevokeRelayPairing" const RevokeRelayPairingURL = pairingBaseURL + "/RevokeRelayPairing"
var MESSAGING = INSTANT_MESSAGING + "/$rpc/google.internal.communications.instantmessaging.v1.Messaging" const messagingBaseURL = instantMessangingBaseURL + "/$rpc/google.internal.communications.instantmessaging.v1.Messaging"
var RECEIVE_MESSAGES = MESSAGING + "/ReceiveMessages" const ReceiveMessagesURL = messagingBaseURL + "/ReceiveMessages"
var SEND_MESSAGE = MESSAGING + "/SendMessage" const SendMessageURL = messagingBaseURL + "/SendMessage"
var ACK_MESSAGES = MESSAGING + "/AckMessages" const AckMessagesURL = messagingBaseURL + "/AckMessages"
var REGISTRATION = INSTANT_MESSAGING + "/$rpc/google.internal.communications.instantmessaging.v1.Registration" const registrationBaseURL = instantMessangingBaseURL + "/$rpc/google.internal.communications.instantmessaging.v1.Registration"
var REGISTER_REFRESH = REGISTRATION + "/RegisterRefresh" const RegisterRefreshURL = registrationBaseURL + "/RegisterRefresh"
var CONFIG_URL = "https://messages.google.com/web/config" const ConfigUrl = "https://messages.google.com/web/config"