Compare commits
4 commits
2c373db8fc
...
cf4484f123
Author | SHA1 | Date | |
---|---|---|---|
cf4484f123 | |||
|
5cfc7b0de4 | ||
|
c6892b7a68 | ||
|
6d393bb9cc |
18 changed files with 190 additions and 88 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,3 +1,15 @@
|
|||
# v0.4.2 (2024-06-16)
|
||||
|
||||
* Added error message if phone doesn't send echo for outgoing message in
|
||||
time.
|
||||
* Added better error messages for some message send failures.
|
||||
* Added logging for RPC request and response IDs.
|
||||
* Fixed sending messages incorrectly forcing RCS in some cases causing failures
|
||||
(e.g. when using dual SIM and sending from a SIM with RCS disabled).
|
||||
* Fixed ping loop getting stuck (and therefore not keeping the connection
|
||||
alive) if the first ping never responds.
|
||||
* Removed unnecessary sleep after Google account pairing.
|
||||
|
||||
# v0.4.1 (2024-05-16)
|
||||
|
||||
* Added support for sending captions.
|
||||
|
|
|
@ -126,6 +126,7 @@ func (portal *Portal) forwardBackfill(ctx context.Context, user *User, after tim
|
|||
}
|
||||
|
||||
log := zerolog.Ctx(ctx)
|
||||
// TODO this should cancel if the context is canceled
|
||||
resp, err := user.Client.FetchMessages(portal.ID, int64(limit), nil)
|
||||
if err != nil {
|
||||
portal.zlog.Error().Err(err).Msg("Failed to fetch messages")
|
||||
|
|
40
commands.go
40
commands.go
|
@ -52,6 +52,8 @@ func (br *GMBridge) RegisterCommands() {
|
|||
cmdDisconnect,
|
||||
cmdSetActive,
|
||||
cmdPing,
|
||||
cmdToggleBatteryNotifications,
|
||||
cmdToggleVerboseNotifications,
|
||||
cmdPM,
|
||||
cmdDeletePortal,
|
||||
cmdDeleteAllPortals,
|
||||
|
@ -402,6 +404,44 @@ func fnPing(ce *WrappedCommandEvent) {
|
|||
}
|
||||
}
|
||||
|
||||
var cmdToggleBatteryNotifications = &commands.FullHandler{
|
||||
Func: wrapCommand(fnToggleBatteryNotifications),
|
||||
Name: "toggle-battery-notifications",
|
||||
Help: commands.HelpMeta{
|
||||
Section: HelpSectionConnectionManagement,
|
||||
Description: "Silence Battery statuses.",
|
||||
},
|
||||
}
|
||||
|
||||
func fnToggleBatteryNotifications(ce *WrappedCommandEvent) {
|
||||
ce.User.toggleNotifyBattery()
|
||||
if ce.User.DisableNotifyBattery {
|
||||
ce.Reply("Disabled battery notifications")
|
||||
} else {
|
||||
ce.Reply("Enabled battery notifications")
|
||||
}
|
||||
ce.ZLog.Trace().Msg("ToggleBatteryNotifications command finished")
|
||||
}
|
||||
|
||||
var cmdToggleVerboseNotifications = &commands.FullHandler{
|
||||
Func: wrapCommand(fnToggleVerboseNotifications),
|
||||
Name: "toggle-verbose-notifications",
|
||||
Help: commands.HelpMeta{
|
||||
Section: HelpSectionConnectionManagement,
|
||||
Description: "Silence Connected statuses when session changes and no data received recently.",
|
||||
},
|
||||
}
|
||||
|
||||
func fnToggleVerboseNotifications(ce *WrappedCommandEvent) {
|
||||
ce.User.toggleNotifyVerbose()
|
||||
if ce.User.DisableNotifyVerbose {
|
||||
ce.Reply("Disabled verbose notifications")
|
||||
} else {
|
||||
ce.Reply("Enabled verbose notifications")
|
||||
}
|
||||
ce.ZLog.Trace().Msg("ToggleVerboseNotifications command finished")
|
||||
}
|
||||
|
||||
var cmdPM = &commands.FullHandler{
|
||||
Func: wrapCommand(fnPM),
|
||||
Name: "pm",
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
||||
)
|
||||
|
||||
func DoUpgrade(helper *up.Helper) {
|
||||
func DoUpgrade(helper up.Helper) {
|
||||
bridgeconfig.Upgrader.DoUpgrade(helper)
|
||||
|
||||
helper.Copy(up.Str|up.Null, "analytics", "host")
|
||||
|
|
3
database/upgrades/11-user-settings.sql
Normal file
3
database/upgrades/11-user-settings.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
-- v11 (compatible with v10+): User settings
|
||||
ALTER TABLE "user" ADD COLUMN disable_notify_battery BOOLEAN NOT NULL DEFAULT false;
|
||||
ALTER TABLE "user" ADD COLUMN disable_notify_verbose BOOLEAN NOT NULL DEFAULT false;
|
|
@ -40,7 +40,7 @@ func newUser(qh *dbutil.QueryHelper[*User]) *User {
|
|||
}
|
||||
|
||||
const (
|
||||
getUserBaseQuery = `SELECT rowid, mxid, phone_id, session, self_participant_ids, sim_metadata, settings, management_room, space_room, access_token FROM "user"`
|
||||
getUserBaseQuery = `SELECT rowid, mxid, phone_id, session, self_participant_ids, sim_metadata, settings, management_room, space_room, access_token, disable_notify_battery, disable_notify_verbose FROM "user"`
|
||||
getAllUsersWithSessionQuery = getUserBaseQuery + " WHERE session IS NOT NULL"
|
||||
getAllUsersWithDoublePuppetQuery = getUserBaseQuery + " WHERE access_token<>''"
|
||||
getUserByRowIDQuery = getUserBaseQuery + " WHERE rowid=$1"
|
||||
|
@ -53,7 +53,8 @@ const (
|
|||
updateUserQuery = `
|
||||
UPDATE "user"
|
||||
SET phone_id=$2, session=$3, self_participant_ids=$4, sim_metadata=$5, settings=$6,
|
||||
management_room=$7, space_room=$8, access_token=$9
|
||||
management_room=$7, space_room=$8, access_token=$9,
|
||||
disable_notify_battery=$10, disable_notify_verbose=$11
|
||||
WHERE mxid=$1
|
||||
`
|
||||
updateuserParticipantIDsQuery = `UPDATE "user" SET self_participant_ids=$2 WHERE mxid=$1`
|
||||
|
@ -103,6 +104,9 @@ type User struct {
|
|||
Settings Settings
|
||||
|
||||
AccessToken string
|
||||
|
||||
DisableNotifyBattery bool
|
||||
DisableNotifyVerbose bool
|
||||
}
|
||||
|
||||
func (user *User) Scan(row dbutil.Scannable) (*User, error) {
|
||||
|
@ -111,6 +115,7 @@ func (user *User) Scan(row dbutil.Scannable) (*User, error) {
|
|||
err := row.Scan(
|
||||
&user.RowID, &user.MXID, &phoneID, &session, &selfParticipantIDs, &simMetadata,
|
||||
&settings, &managementRoom, &spaceRoom, &accessToken,
|
||||
&user.DisableNotifyBattery, &user.DisableNotifyVerbose,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -169,6 +174,7 @@ func (user *User) sqlVariables() []any {
|
|||
return []any{
|
||||
user.MXID, dbutil.StrPtr(user.PhoneID), session, string(selfParticipantIDs), string(simMetadata),
|
||||
string(settings), dbutil.StrPtr(user.ManagementRoom), dbutil.StrPtr(user.SpaceRoom), dbutil.StrPtr(user.AccessToken),
|
||||
user.DisableNotifyBattery, user.DisableNotifyVerbose,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
23
go.mod
23
go.mod
|
@ -3,17 +3,16 @@ module go.mau.fi/mautrix-gmessages
|
|||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/beeper/libserv v0.0.0-20231231202820-c7303abfc32c
|
||||
github.com/gabriel-vasile/mimetype v1.4.3
|
||||
github.com/gabriel-vasile/mimetype v1.4.4
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/mattn/go-sqlite3 v1.14.22
|
||||
github.com/rs/zerolog v1.32.0
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
go.mau.fi/mautrix-gmessages/libgm v0.4.1
|
||||
go.mau.fi/util v0.4.2
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
|
||||
google.golang.org/protobuf v1.34.1
|
||||
maunium.net/go/mautrix v0.18.1
|
||||
go.mau.fi/mautrix-gmessages/libgm v0.4.2
|
||||
go.mau.fi/util v0.5.0
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
|
||||
google.golang.org/protobuf v1.34.2
|
||||
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617151654-afeadfb15fee
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -30,11 +29,11 @@ require (
|
|||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
github.com/yuin/goldmark v1.7.1 // indirect
|
||||
github.com/yuin/goldmark v1.7.2 // indirect
|
||||
go.mau.fi/zeroconfig v0.1.2 // indirect
|
||||
golang.org/x/crypto v0.23.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.24.0 // indirect
|
||||
golang.org/x/net v0.26.0 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
|
42
go.sum
42
go.sum
|
@ -1,14 +1,12 @@
|
|||
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
|
||||
github.com/beeper/libserv v0.0.0-20231231202820-c7303abfc32c h1:WqjRVgUO039eiISCjsZC4F9onOEV93DJAk6v33rsZzY=
|
||||
github.com/beeper/libserv v0.0.0-20231231202820-c7303abfc32c/go.mod h1:b9FFm9y4mEm36G8ytVmS1vkNzJa0KepmcdVY+qf7qRU=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
|
||||
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
|
@ -43,8 +41,8 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
|
|||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
|
@ -58,25 +56,25 @@ github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
|||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
||||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||
github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U=
|
||||
github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
go.mau.fi/util v0.4.2 h1:RR3TOcRHmCF9Bx/3YG4S65MYfa+nV6/rn8qBWW4Mi30=
|
||||
go.mau.fi/util v0.4.2/go.mod h1:PlAVfUUcPyHPrwnvjkJM9UFcPE7qGPDJqk+Oufa1Gtw=
|
||||
github.com/yuin/goldmark v1.7.2 h1:NjGd7lO7zrUn/A7eKwn5PEOt4ONYGqpxSEeZuduvgxc=
|
||||
github.com/yuin/goldmark v1.7.2/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
|
||||
go.mau.fi/util v0.5.0 h1:8yELAl+1CDRrwGe9NUmREgVclSs26Z68pTWePHVxuDo=
|
||||
go.mau.fi/util v0.5.0/go.mod h1:DsJzUrJAG53lCZnnYvq9/mOyLuPScWwYhvETiTrpdP4=
|
||||
go.mau.fi/zeroconfig v0.1.2 h1:DKOydWnhPMn65GbXZOafgkPm11BvFashZWLct0dGFto=
|
||||
go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
|
||||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
|
||||
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
|
||||
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
@ -86,5 +84,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
|
||||
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
|
||||
maunium.net/go/mautrix v0.18.1 h1:a6mUsJixegBNTXUoqC5RQ9gsumIPzKvCubKwF+zmCt4=
|
||||
maunium.net/go/mautrix v0.18.1/go.mod h1:2oHaq792cSXFGvxLvYw3Gf1L4WVVP4KZcYys5HVk/h8=
|
||||
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617151654-afeadfb15fee h1:CQyItqakHeYb19uj1FAooHVMK53e45TjoINGmcnKsLc=
|
||||
maunium.net/go/mautrix v0.19.0-beta.1.0.20240617151654-afeadfb15fee/go.mod h1:cxv1w6+syudmEpOewHYIQT9yO7TM5UOWmf6xEBVI4H4=
|
||||
|
|
|
@ -19,6 +19,8 @@ type GaiaLoggedOut struct{}
|
|||
|
||||
type NoDataReceived struct{}
|
||||
|
||||
type RecentlyDisconnected struct{}
|
||||
|
||||
type AccountChange struct {
|
||||
*gmproto.AccountChangeOrSomethingEvent
|
||||
IsFake bool
|
||||
|
|
|
@ -3,19 +3,19 @@ module go.mau.fi/mautrix-gmessages/libgm/gmtest
|
|||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/rs/zerolog v1.32.0
|
||||
go.mau.fi/mautrix-gmessages/libgm v0.4.0
|
||||
github.com/rs/zerolog v1.33.0
|
||||
go.mau.fi/mautrix-gmessages/libgm v0.4.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
go.mau.fi/util v0.4.2 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
go.mau.fi/util v0.5.0 // indirect
|
||||
golang.org/x/crypto v0.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
)
|
||||
|
||||
replace go.mau.fi/mautrix-gmessages/libgm => ../
|
||||
|
|
|
@ -2,8 +2,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
|
|||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
|
@ -16,22 +16,22 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
|||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.mau.fi/util v0.4.2 h1:RR3TOcRHmCF9Bx/3YG4S65MYfa+nV6/rn8qBWW4Mi30=
|
||||
go.mau.fi/util v0.4.2/go.mod h1:PlAVfUUcPyHPrwnvjkJM9UFcPE7qGPDJqk+Oufa1Gtw=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 h1:ESSUROHIBHg7USnszlcdmjBEwdMj9VUvU+OPk4yl2mc=
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
|
||||
go.mau.fi/util v0.5.0 h1:8yELAl+1CDRrwGe9NUmREgVclSs26Z68pTWePHVxuDo=
|
||||
go.mau.fi/util v0.5.0/go.mod h1:DsJzUrJAG53lCZnnYvq9/mOyLuPScWwYhvETiTrpdP4=
|
||||
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
|
||||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
12
libgm/go.mod
12
libgm/go.mod
|
@ -4,12 +4,12 @@ go 1.21
|
|||
|
||||
require (
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/rs/zerolog v1.32.0
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
go.mau.fi/util v0.4.2
|
||||
golang.org/x/crypto v0.22.0
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8
|
||||
google.golang.org/protobuf v1.33.0
|
||||
go.mau.fi/util v0.5.0
|
||||
golang.org/x/crypto v0.24.0
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
|
||||
google.golang.org/protobuf v1.34.2
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -17,6 +17,6 @@ require (
|
|||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
28
libgm/go.sum
28
libgm/go.sum
|
@ -2,8 +2,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
|
|||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
|
@ -15,23 +15,23 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
|||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.mau.fi/util v0.4.2 h1:RR3TOcRHmCF9Bx/3YG4S65MYfa+nV6/rn8qBWW4Mi30=
|
||||
go.mau.fi/util v0.4.2/go.mod h1:PlAVfUUcPyHPrwnvjkJM9UFcPE7qGPDJqk+Oufa1Gtw=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 h1:ESSUROHIBHg7USnszlcdmjBEwdMj9VUvU+OPk4yl2mc=
|
||||
golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
|
||||
go.mau.fi/util v0.5.0 h1:8yELAl+1CDRrwGe9NUmREgVclSs26Z68pTWePHVxuDo=
|
||||
go.mau.fi/util v0.5.0/go.mod h1:DsJzUrJAG53lCZnnYvq9/mOyLuPScWwYhvETiTrpdP4=
|
||||
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
|
||||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
|
||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
|
|
@ -240,7 +240,7 @@ func (dp *dittoPinger) Loop() {
|
|||
go dp.HandleNoRecentUpdates()
|
||||
} else if time.Since(pingStart) > 5*time.Minute {
|
||||
dp.log.Warn().Msg("Was disconnected for over 5 minutes, sending extra GET_UPDATES call")
|
||||
go dp.HandleNoRecentUpdates()
|
||||
go dp.HandleRecentlyDisconnected()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,6 +259,20 @@ func (dp *dittoPinger) HandleNoRecentUpdates() {
|
|||
}
|
||||
}
|
||||
|
||||
func (dp *dittoPinger) HandleRecentlyDisconnected() {
|
||||
dp.client.triggerEvent(&events.RecentlyDisconnected{})
|
||||
err := dp.client.sessionHandler.sendMessageNoResponse(SendMessageParams{
|
||||
Action: gmproto.ActionType_GET_UPDATES,
|
||||
OmitTTL: true,
|
||||
RequestID: dp.client.sessionHandler.sessionID,
|
||||
})
|
||||
if err != nil {
|
||||
dp.log.Err(err).Msg("Failed to send extra GET_UPDATES call")
|
||||
} else {
|
||||
dp.log.Debug().Msg("Sent extra GET_UPDATES call")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) shouldDoDataReceiveCheck() bool {
|
||||
c.nextDataReceiveCheckLock.Lock()
|
||||
defer c.nextDataReceiveCheckLock.Unlock()
|
||||
|
|
2
main.go
2
main.go
|
@ -172,7 +172,7 @@ func main() {
|
|||
Name: "mautrix-gmessages",
|
||||
URL: "https://github.com/mautrix/gmessages",
|
||||
Description: "A Matrix-Google Messages puppeting bridge.",
|
||||
Version: "0.4.1",
|
||||
Version: "0.4.2",
|
||||
ProtocolName: "Google Messages",
|
||||
BeeperServiceName: "gmessages",
|
||||
BeeperNetworkName: "gmessages",
|
||||
|
|
|
@ -1740,7 +1740,7 @@ func (portal *Portal) CreateMatrixRoom(ctx context.Context, user *User, conv *gm
|
|||
initialState = append(initialState, &event.Event{
|
||||
Type: event.StateRoomAvatar,
|
||||
Content: event.Content{
|
||||
Parsed: &event.RoomAvatarEventContent{URL: avatarURL},
|
||||
Parsed: &event.RoomAvatarEventContent{URL: avatarURL.CUString()},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -25,11 +25,10 @@ import (
|
|||
_ "net/http/pprof"
|
||||
"strings"
|
||||
|
||||
"github.com/beeper/libserv/pkg/requestlog"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/hlog"
|
||||
"go.mau.fi/util/requestlog"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"maunium.net/go/mautrix/bridge/status"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
|
|
32
user.go
32
user.go
|
@ -79,6 +79,7 @@ type User struct {
|
|||
phoneNotRespondingAlertSent bool
|
||||
didHackySetActive bool
|
||||
noDataReceivedRecently bool
|
||||
recentlyDisconnected bool
|
||||
lastDataReceived time.Time
|
||||
gaiaHackyDeviceSwitcher int
|
||||
|
||||
|
@ -291,7 +292,7 @@ func (user *User) GetSpaceRoom(ctx context.Context) id.RoomID {
|
|||
Type: event.StateRoomAvatar,
|
||||
Content: event.Content{
|
||||
Parsed: &event.RoomAvatarEventContent{
|
||||
URL: user.bridge.Config.AppService.Bot.ParsedAvatar,
|
||||
URL: user.bridge.Config.AppService.Bot.ParsedAvatar.CUString(),
|
||||
},
|
||||
},
|
||||
}},
|
||||
|
@ -660,6 +661,7 @@ func (user *User) DeleteSession() {
|
|||
user.SelfParticipantIDs = []string{}
|
||||
user.didHackySetActive = false
|
||||
user.noDataReceivedRecently = false
|
||||
user.recentlyDisconnected = false
|
||||
user.lastDataReceived = time.Time{}
|
||||
err := user.Update(context.TODO())
|
||||
if err != nil {
|
||||
|
@ -849,6 +851,8 @@ func (user *User) syncHandleEvent(event any) {
|
|||
user.handleSettings(v)
|
||||
case *events.AccountChange:
|
||||
user.handleAccountChange(v)
|
||||
case *events.RecentlyDisconnected:
|
||||
user.recentlyDisconnected = true
|
||||
case *events.NoDataReceived:
|
||||
user.noDataReceivedRecently = true
|
||||
default:
|
||||
|
@ -970,17 +974,20 @@ func (user *User) handleUserAlert(v *gmproto.UserAlertEvent) {
|
|||
user.ready = true
|
||||
newSessionID := user.Client.CurrentSessionID()
|
||||
sessionIDChanged := user.sessionID != newSessionID
|
||||
if sessionIDChanged || wasInactive || user.noDataReceivedRecently {
|
||||
if sessionIDChanged || wasInactive || user.noDataReceivedRecently || user.recentlyDisconnected {
|
||||
user.zlog.Debug().
|
||||
Str("old_session_id", user.sessionID).
|
||||
Str("new_session_id", newSessionID).
|
||||
Bool("was_inactive", wasInactive).
|
||||
Bool("had_no_data_received", user.noDataReceivedRecently).
|
||||
Bool("recently_disconeccted", user.recentlyDisconnected).
|
||||
Time("last_data_received", user.lastDataReceived).
|
||||
Msg("Session ID changed for browser active event, resyncing")
|
||||
user.sessionID = newSessionID
|
||||
go user.fetchAndSyncConversations(user.lastDataReceived, !sessionIDChanged && !wasInactive)
|
||||
if (!user.DisableNotifyVerbose || wasInactive || user.recentlyDisconnected) {
|
||||
go user.sendMarkdownBridgeAlert(ctx, false, "Connected to Google Messages")
|
||||
}
|
||||
} else {
|
||||
user.zlog.Debug().
|
||||
Str("session_id", user.sessionID).
|
||||
|
@ -990,6 +997,7 @@ func (user *User) handleUserAlert(v *gmproto.UserAlertEvent) {
|
|||
Msg("Session ID didn't change for browser active event, not resyncing")
|
||||
}
|
||||
user.noDataReceivedRecently = false
|
||||
user.recentlyDisconnected = false
|
||||
user.lastDataReceived = time.Now()
|
||||
case gmproto.AlertType_BROWSER_INACTIVE_FROM_TIMEOUT:
|
||||
user.browserInactiveType = GMBrowserInactiveTimeout
|
||||
|
@ -1004,13 +1012,17 @@ func (user *User) handleUserAlert(v *gmproto.UserAlertEvent) {
|
|||
case gmproto.AlertType_MOBILE_BATTERY_LOW:
|
||||
user.batteryLow = true
|
||||
if time.Since(user.batteryLowAlertSent) > 30*time.Minute {
|
||||
if (!user.DisableNotifyBattery) {
|
||||
go user.sendMarkdownBridgeAlert(ctx, true, "Your phone's battery is low")
|
||||
}
|
||||
user.batteryLowAlertSent = time.Now()
|
||||
}
|
||||
case gmproto.AlertType_MOBILE_BATTERY_RESTORED:
|
||||
user.batteryLow = false
|
||||
if !user.batteryLowAlertSent.IsZero() {
|
||||
if (!user.DisableNotifyBattery) {
|
||||
go user.sendMarkdownBridgeAlert(ctx, false, "Phone battery restored")
|
||||
}
|
||||
user.batteryLowAlertSent = time.Time{}
|
||||
}
|
||||
default:
|
||||
|
@ -1026,6 +1038,22 @@ func (user *User) handleUserAlert(v *gmproto.UserAlertEvent) {
|
|||
user.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected})
|
||||
}
|
||||
|
||||
func (user *User) toggleNotifyBattery() {
|
||||
user.DisableNotifyBattery = !user.DisableNotifyBattery
|
||||
err := user.Update(context.TODO())
|
||||
if err != nil {
|
||||
user.zlog.Err(err).Msg("Failed to save notify battery preference")
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) toggleNotifyVerbose() {
|
||||
user.DisableNotifyVerbose = !user.DisableNotifyVerbose
|
||||
err := user.Update(context.TODO())
|
||||
if err != nil {
|
||||
user.zlog.Err(err).Msg("Failed to save notify verbose preference")
|
||||
}
|
||||
}
|
||||
|
||||
func (user *User) handleSettings(settings *gmproto.Settings) {
|
||||
if settings.SIMCards == nil {
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue