diff --git a/config/upgrade.go b/config/upgrade.go index 4a9dfe1..11edb5f 100644 --- a/config/upgrade.go +++ b/config/upgrade.go @@ -17,9 +17,9 @@ package config import ( + up "go.mau.fi/util/configupgrade" + "go.mau.fi/util/random" "maunium.net/go/mautrix/bridge/bridgeconfig" - "maunium.net/go/mautrix/util" - up "maunium.net/go/mautrix/util/configupgrade" ) func DoUpgrade(helper *up.Helper) { @@ -88,7 +88,7 @@ func DoUpgrade(helper *up.Helper) { helper.Copy(up.Bool, "bridge", "encryption", "rotation", "disable_device_change_key_rotation") helper.Copy(up.Str, "bridge", "provisioning", "prefix") if secret, ok := helper.Get(up.Str, "bridge", "provisioning", "shared_secret"); !ok || secret == "generate" { - sharedSecret := util.RandomString(64) + sharedSecret := random.String(64) helper.Set(up.Str, sharedSecret, "bridge", "provisioning", "shared_secret") } else { helper.Copy(up.Str, "bridge", "provisioning", "shared_secret") diff --git a/database/database.go b/database/database.go index 60f7c40..5c17b09 100644 --- a/database/database.go +++ b/database/database.go @@ -20,7 +20,7 @@ import ( "context" _ "github.com/mattn/go-sqlite3" - "maunium.net/go/mautrix/util/dbutil" + "go.mau.fi/util/dbutil" "go.mau.fi/mautrix-gmessages/database/upgrades" ) diff --git a/database/message.go b/database/message.go index a7a9fb7..311c11f 100644 --- a/database/message.go +++ b/database/message.go @@ -24,8 +24,8 @@ import ( "strings" "time" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) diff --git a/database/portal.go b/database/portal.go index 4542884..59b068a 100644 --- a/database/portal.go +++ b/database/portal.go @@ -23,8 +23,8 @@ import ( "fmt" "github.com/rs/zerolog" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" "go.mau.fi/mautrix-gmessages/libgm/gmproto" ) diff --git a/database/puppet.go b/database/puppet.go index 702dd54..c9be16d 100644 --- a/database/puppet.go +++ b/database/puppet.go @@ -21,8 +21,8 @@ import ( "database/sql" "errors" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type PuppetQuery struct { diff --git a/database/reaction.go b/database/reaction.go index 056b34b..6038df0 100644 --- a/database/reaction.go +++ b/database/reaction.go @@ -23,8 +23,8 @@ import ( "fmt" "strings" + "go.mau.fi/util/dbutil" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" ) type ReactionQuery struct { diff --git a/database/upgrades/upgrades.go b/database/upgrades/upgrades.go index 4bea89a..1227230 100644 --- a/database/upgrades/upgrades.go +++ b/database/upgrades/upgrades.go @@ -19,7 +19,7 @@ package upgrades import ( "embed" - "maunium.net/go/mautrix/util/dbutil" + "go.mau.fi/util/dbutil" ) var Table dbutil.UpgradeTable diff --git a/database/user.go b/database/user.go index 0335b0d..23804e3 100644 --- a/database/user.go +++ b/database/user.go @@ -24,9 +24,9 @@ import ( "fmt" "sync" + "go.mau.fi/util/dbutil" "golang.org/x/exp/slices" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/dbutil" "go.mau.fi/mautrix-gmessages/libgm" ) diff --git a/go.mod b/go.mod index 78fa6b2..45d56f0 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,14 @@ go 1.20 require ( github.com/gabriel-vasile/mimetype v1.4.2 github.com/mattn/go-sqlite3 v1.14.17 - github.com/rs/zerolog v1.29.1 + github.com/rs/zerolog v1.30.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e go.mau.fi/mautrix-gmessages/libgm v0.1.0 + go.mau.fi/util v0.0.0-20230805161919-cf42c11d39c3 golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 google.golang.org/protobuf v1.31.0 maunium.net/go/maulogger/v2 v2.4.1 - maunium.net/go/mautrix v0.15.5-0.20230728182848-1ef656165098 + maunium.net/go/mautrix v0.15.5-0.20230805162445-fd1cdd8c9457 ) require ( diff --git a/go.sum b/go.sum index 517ef9a..4365b5c 100644 --- a/go.sum +++ b/go.sum @@ -37,9 +37,9 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= 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.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= @@ -54,6 +54,8 @@ 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.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU= github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mau.fi/util v0.0.0-20230805161919-cf42c11d39c3 h1:r3Hrayw0CfmkrDhse7SbClYzq0e7/5P3iKpyV+gW16w= +go.mau.fi/util v0.0.0-20230805161919-cf42c11d39c3/go.mod h1:tNxQ2KpD+QhP2MlMfJvFSGSJfDjg4OhIwP7bIK43X/I= 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.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= @@ -81,5 +83,5 @@ 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/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8= maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho= -maunium.net/go/mautrix v0.15.5-0.20230728182848-1ef656165098 h1:1MA35IEVXHzgFnJEcgAoawNcDedRZjXoHdwylhPURLs= -maunium.net/go/mautrix v0.15.5-0.20230728182848-1ef656165098/go.mod h1:dBaDmsnOOBM4a+gKcgefXH73pHGXm+MCJzCs1dXFgrw= +maunium.net/go/mautrix v0.15.5-0.20230805162445-fd1cdd8c9457 h1:VBKrYpAojLXdvR0RKi6uLqUmmfQLAf96SRdHv1G9occ= +maunium.net/go/mautrix v0.15.5-0.20230805162445-fd1cdd8c9457/go.mod h1:gpOJUT7EgK7vZTbewOrhWzNNjjJqwVahGRfTVg3BQko= diff --git a/main.go b/main.go index 6bca5d5..1d62676 100644 --- a/main.go +++ b/main.go @@ -20,11 +20,11 @@ import ( _ "embed" "sync" + "go.mau.fi/util/configupgrade" "maunium.net/go/mautrix/bridge" "maunium.net/go/mautrix/bridge/commands" "maunium.net/go/mautrix/bridge/status" "maunium.net/go/mautrix/id" - "maunium.net/go/mautrix/util/configupgrade" "go.mau.fi/mautrix-gmessages/config" "go.mau.fi/mautrix-gmessages/database" diff --git a/portal.go b/portal.go index 31432f3..5e19249 100644 --- a/portal.go +++ b/portal.go @@ -29,9 +29,8 @@ import ( "github.com/gabriel-vasile/mimetype" "github.com/rs/zerolog" - mutil "maunium.net/go/mautrix/util" - "maunium.net/go/mautrix/util/variationselector" - + "go.mau.fi/util/exerrors" + "go.mau.fi/util/variationselector" "maunium.net/go/mautrix" "maunium.net/go/mautrix/appservice" "maunium.net/go/mautrix/bridge" @@ -1303,12 +1302,12 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, co } data, err := portal.MainIntent().DownloadBytesContext(ctx, url) if err != nil { - return nil, mutil.NewDualError(errMediaDownloadFailed, err) + return nil, exerrors.NewDualError(errMediaDownloadFailed, err) } if content.File != nil { err = content.File.DecryptInPlace(data) if err != nil { - return nil, mutil.NewDualError(errMediaDecryptFailed, err) + return nil, exerrors.NewDualError(errMediaDecryptFailed, err) } } if content.Info.MimeType == "" { @@ -1320,7 +1319,7 @@ func (portal *Portal) convertMatrixMessage(ctx context.Context, sender *User, co } resp, err := sender.Client.UploadMedia(data, fileName, content.Info.MimeType) if err != nil { - return nil, mutil.NewDualError(errMediaReuploadFailed, err) + return nil, exerrors.NewDualError(errMediaReuploadFailed, err) } req.MessagePayload.MessageInfo = []*gmproto.MessageInfo{{ Data: &gmproto.MessageInfo_MediaContent{MediaContent: resp},