Skip to content

Commit

Permalink
Adjust constants and defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 24, 2023
1 parent 6f21016 commit 5f47cbc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions config/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ var SpacedBlocks = [][]string{
{"appservice", "as_token"},
{"segment_key"},
{"metrics"},
{"google_messages"},
{"bridge"},
{"bridge", "command_prefix"},
{"bridge", "management_room_text"},
Expand Down
4 changes: 2 additions & 2 deletions example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ metrics:

google_messages:
# OS name to tell the phone. This is the name that shows up in the paired devices list.
os: mautrix-gmessages
os: Android (mautrix)
# Browser type to tell the phone. This decides which icon is shown.
# Valid types: OTHER, CHROME, FIREFOX, SAFARI, OPERA, IE, EDGE
browser: OTHER
browser: CHROME
# Device type to tell the phone. This also affects the icon, as well as how many sessions are allowed simultaneously.
# One web, two tablets and one PWA should be able to connect at the same time.
# Valid types: WEB, TABLET, PWA
Expand Down
5 changes: 3 additions & 2 deletions libgm/util/constants.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package util

const GoogleAPIKey = "AIzaSyCA4RsOZUFrm9whhtGosPlJLmVPnfSHKz8"
const UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
const UserAgent = "Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
const SecUA = `"Google Chrome";v="113", "Chromium";v="113", "Not-A.Brand";v="24"`
const UAPlatform = "Linux"
const UAPlatform = "Android"
const XUserAgent = "grpc-web-javascript/0.1"
const QRCodeURLBase = "https://support.google.com/messages/?p=web_computer#?c="
const SecUAMobile = "?1"
6 changes: 3 additions & 3 deletions libgm/util/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func BuildRelayHeaders(req *http.Request, contentType string, accept string) {
if len(contentType) > 0 {
req.Header.Add("content-type", contentType)
}
req.Header.Add("sec-ch-ua-mobile", "?0")
req.Header.Add("sec-ch-ua-mobile", SecUAMobile)
req.Header.Add("user-agent", UserAgent)
req.Header.Add("sec-ch-ua-platform", "\""+UAPlatform+"\"")
req.Header.Add("accept", accept)
Expand All @@ -44,7 +44,7 @@ func BuildUploadHeaders(req *http.Request, metadata string) {
req.Header.Add("connection", "keep-alive")
req.Header.Add("x-goog-download-metadata", metadata)
req.Header.Add("sec-ch-ua", SecUA)
req.Header.Add("sec-ch-ua-mobile", "?0")
req.Header.Add("sec-ch-ua-mobile", SecUAMobile)
req.Header.Add("user-agent", UserAgent)
req.Header.Add("sec-ch-ua-platform", "\""+UAPlatform+"\"")
req.Header.Add("accept", "*/*")
Expand All @@ -67,7 +67,7 @@ func NewMediaUploadHeaders(imageSize string, command string, uploadOffset string
headers.Add("x-goog-upload-protocol", protocol)
}
headers.Add("x-goog-upload-header-content-length", imageSize)
headers.Add("sec-ch-ua-mobile", "?0")
headers.Add("sec-ch-ua-mobile", SecUAMobile)
headers.Add("user-agent", UserAgent)
if imageContentType != "" {
headers.Add("x-goog-upload-header-content-type", imageContentType)
Expand Down
2 changes: 1 addition & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (user *User) Login(maxAttempts int) (<-chan qrChannelItem, error) {
user.createClient(libgm.NewAuthData())
qr, err := user.Client.StartLogin()
if err != nil {
user.DeleteConnection()
user.unlockedDeleteConnection()
user.pairSuccessChan = nil
user.loginInProgress.Store(false)
return nil, fmt.Errorf("failed to connect to Google Messages: %w", err)
Expand Down

0 comments on commit 5f47cbc

Please sign in to comment.