Update mautrix-go
This commit is contained in:
parent
a21a556c57
commit
c3be0a30fa
12 changed files with 26 additions and 24 deletions
|
@ -17,9 +17,9 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
up "go.mau.fi/util/configupgrade"
|
||||||
|
"go.mau.fi/util/random"
|
||||||
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
"maunium.net/go/mautrix/bridge/bridgeconfig"
|
||||||
"maunium.net/go/mautrix/util"
|
|
||||||
up "maunium.net/go/mautrix/util/configupgrade"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func DoUpgrade(helper *up.Helper) {
|
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.Bool, "bridge", "encryption", "rotation", "disable_device_change_key_rotation")
|
||||||
helper.Copy(up.Str, "bridge", "provisioning", "prefix")
|
helper.Copy(up.Str, "bridge", "provisioning", "prefix")
|
||||||
if secret, ok := helper.Get(up.Str, "bridge", "provisioning", "shared_secret"); !ok || secret == "generate" {
|
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")
|
helper.Set(up.Str, sharedSecret, "bridge", "provisioning", "shared_secret")
|
||||||
} else {
|
} else {
|
||||||
helper.Copy(up.Str, "bridge", "provisioning", "shared_secret")
|
helper.Copy(up.Str, "bridge", "provisioning", "shared_secret")
|
||||||
|
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"maunium.net/go/mautrix/util/dbutil"
|
"go.mau.fi/util/dbutil"
|
||||||
|
|
||||||
"go.mau.fi/mautrix-gmessages/database/upgrades"
|
"go.mau.fi/mautrix-gmessages/database/upgrades"
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,8 +24,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.mau.fi/util/dbutil"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
"maunium.net/go/mautrix/util/dbutil"
|
|
||||||
|
|
||||||
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
|
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,8 +23,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
|
"go.mau.fi/util/dbutil"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
"maunium.net/go/mautrix/util/dbutil"
|
|
||||||
|
|
||||||
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
|
"go.mau.fi/mautrix-gmessages/libgm/gmproto"
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,8 +21,8 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"go.mau.fi/util/dbutil"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
"maunium.net/go/mautrix/util/dbutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PuppetQuery struct {
|
type PuppetQuery struct {
|
||||||
|
|
|
@ -23,8 +23,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.mau.fi/util/dbutil"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
"maunium.net/go/mautrix/util/dbutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ReactionQuery struct {
|
type ReactionQuery struct {
|
||||||
|
|
|
@ -19,7 +19,7 @@ package upgrades
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
|
||||||
"maunium.net/go/mautrix/util/dbutil"
|
"go.mau.fi/util/dbutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Table dbutil.UpgradeTable
|
var Table dbutil.UpgradeTable
|
||||||
|
|
|
@ -24,9 +24,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"go.mau.fi/util/dbutil"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
"maunium.net/go/mautrix/util/dbutil"
|
|
||||||
|
|
||||||
"go.mau.fi/mautrix-gmessages/libgm"
|
"go.mau.fi/mautrix-gmessages/libgm"
|
||||||
)
|
)
|
||||||
|
|
5
go.mod
5
go.mod
|
@ -5,13 +5,14 @@ go 1.20
|
||||||
require (
|
require (
|
||||||
github.com/gabriel-vasile/mimetype v1.4.2
|
github.com/gabriel-vasile/mimetype v1.4.2
|
||||||
github.com/mattn/go-sqlite3 v1.14.17
|
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
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||||
go.mau.fi/mautrix-gmessages/libgm v0.1.0
|
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
|
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
|
||||||
google.golang.org/protobuf v1.31.0
|
google.golang.org/protobuf v1.31.0
|
||||||
maunium.net/go/maulogger/v2 v2.4.1
|
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 (
|
require (
|
||||||
|
|
12
go.sum
12
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.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 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
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/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
|
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
|
||||||
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
|
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 h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
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=
|
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/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 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU=
|
||||||
github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
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 h1:DKOydWnhPMn65GbXZOafgkPm11BvFashZWLct0dGFto=
|
||||||
go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
|
go.mau.fi/zeroconfig v0.1.2/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
|
||||||
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
|
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/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 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8=
|
||||||
maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho=
|
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.20230805162445-fd1cdd8c9457 h1:VBKrYpAojLXdvR0RKi6uLqUmmfQLAf96SRdHv1G9occ=
|
||||||
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/go.mod h1:gpOJUT7EgK7vZTbewOrhWzNNjjJqwVahGRfTVg3BQko=
|
||||||
|
|
2
main.go
2
main.go
|
@ -20,11 +20,11 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"go.mau.fi/util/configupgrade"
|
||||||
"maunium.net/go/mautrix/bridge"
|
"maunium.net/go/mautrix/bridge"
|
||||||
"maunium.net/go/mautrix/bridge/commands"
|
"maunium.net/go/mautrix/bridge/commands"
|
||||||
"maunium.net/go/mautrix/bridge/status"
|
"maunium.net/go/mautrix/bridge/status"
|
||||||
"maunium.net/go/mautrix/id"
|
"maunium.net/go/mautrix/id"
|
||||||
"maunium.net/go/mautrix/util/configupgrade"
|
|
||||||
|
|
||||||
"go.mau.fi/mautrix-gmessages/config"
|
"go.mau.fi/mautrix-gmessages/config"
|
||||||
"go.mau.fi/mautrix-gmessages/database"
|
"go.mau.fi/mautrix-gmessages/database"
|
||||||
|
|
11
portal.go
11
portal.go
|
@ -29,9 +29,8 @@ import (
|
||||||
|
|
||||||
"github.com/gabriel-vasile/mimetype"
|
"github.com/gabriel-vasile/mimetype"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
mutil "maunium.net/go/mautrix/util"
|
"go.mau.fi/util/exerrors"
|
||||||
"maunium.net/go/mautrix/util/variationselector"
|
"go.mau.fi/util/variationselector"
|
||||||
|
|
||||||
"maunium.net/go/mautrix"
|
"maunium.net/go/mautrix"
|
||||||
"maunium.net/go/mautrix/appservice"
|
"maunium.net/go/mautrix/appservice"
|
||||||
"maunium.net/go/mautrix/bridge"
|
"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)
|
data, err := portal.MainIntent().DownloadBytesContext(ctx, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, mutil.NewDualError(errMediaDownloadFailed, err)
|
return nil, exerrors.NewDualError(errMediaDownloadFailed, err)
|
||||||
}
|
}
|
||||||
if content.File != nil {
|
if content.File != nil {
|
||||||
err = content.File.DecryptInPlace(data)
|
err = content.File.DecryptInPlace(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, mutil.NewDualError(errMediaDecryptFailed, err)
|
return nil, exerrors.NewDualError(errMediaDecryptFailed, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if content.Info.MimeType == "" {
|
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)
|
resp, err := sender.Client.UploadMedia(data, fileName, content.Info.MimeType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, mutil.NewDualError(errMediaReuploadFailed, err)
|
return nil, exerrors.NewDualError(errMediaReuploadFailed, err)
|
||||||
}
|
}
|
||||||
req.MessagePayload.MessageInfo = []*gmproto.MessageInfo{{
|
req.MessagePayload.MessageInfo = []*gmproto.MessageInfo{{
|
||||||
Data: &gmproto.MessageInfo_MediaContent{MediaContent: resp},
|
Data: &gmproto.MessageInfo_MediaContent{MediaContent: resp},
|
||||||
|
|
Loading…
Reference in a new issue