Compare commits

...

3 Commits

Author SHA1 Message Date
Jarno Rankinen f3f6b8e23f Rename package, bump Go to 1.22 2024-03-24 14:22:00 +02:00
Jarno Rankinen 2e905544ae Add Dockerfile for debugger 2024-03-24 14:03:58 +02:00
Jarno Rankinen 11f515a0bd Bump go version to 1.18 2022-11-10 21:44:36 +02:00
19 changed files with 118 additions and 75 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
__debug_bin*
config.yaml
registration.yaml
logs/
matrix-skype.db

14
Dockerfile.debug Normal file
View File

@ -0,0 +1,14 @@
FROM golang:1.22-alpine
RUN apk add --no-cache ffmpeg su-exec ca-certificates olm olm-dev bash jq yq curl git build-base
RUN go install github.com/go-delve/delve/cmd/dlv@latest
COPY . /src
WORKDIR /src
RUN go get
ENV UID=1337 \
GID=1337
CMD ["dlv", "debug", "--headless", "--listen=:2345", "--api-version=2", "--accept-multiclient"]

View File

@ -5,9 +5,9 @@ import (
"fmt"
"math"
"github.com/0ranki/matrix-skype/database"
skypeExt "github.com/0ranki/matrix-skype/skype-ext"
skype "github.com/kelaresg/go-skypeapi"
"github.com/kelaresg/matrix-skype/database"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
"maunium.net/go/mautrix/patch"
"sort"
@ -388,8 +388,8 @@ func (handler *CommandHandler) CommandPing(ce *CommandEvent) {
}
ce.Reply("You're logged in as @" + username + ", orgid is " + orgId)
}
var password string;
var username string;
var password string
var username string
ret := ce.User.bridge.DB.User.GetCredentialsByMXID(ce.User.MXID, &password, &username)
if ret && password != "" {
ce.Reply("WARNING, your password is stored in database. Use command `remove-password` to remove it.")

View File

@ -11,7 +11,7 @@ import (
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/types"
)
type BridgeConfig struct {

View File

@ -30,7 +30,7 @@ import (
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
"github.com/kelaresg/matrix-skype/database"
"github.com/0ranki/matrix-skype/database"
)
var levelTrace = maulogger.Level{

View File

@ -24,7 +24,7 @@ import (
log "maunium.net/go/maulogger/v2"
"github.com/kelaresg/matrix-skype/database/upgrades"
"github.com/0ranki/matrix-skype/database/upgrades"
)
type Database struct {

View File

@ -6,7 +6,7 @@ import (
"encoding/json"
log "maunium.net/go/maulogger/v2"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/types"
"maunium.net/go/mautrix/id"
)

View File

@ -2,14 +2,14 @@ package database
import (
"database/sql"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
skypeExt "github.com/0ranki/matrix-skype/skype-ext"
"strings"
log "maunium.net/go/maulogger/v2"
"maunium.net/go/mautrix/id"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/types"
)
type PortalKey struct {

View File

@ -5,7 +5,7 @@ import (
log "maunium.net/go/maulogger/v2"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/types"
"maunium.net/go/mautrix/id"
)

View File

@ -3,14 +3,14 @@ package database
import (
"database/sql"
"fmt"
skypeExt "github.com/0ranki/matrix-skype/skype-ext"
skype "github.com/kelaresg/go-skypeapi"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
"strings"
"time"
log "maunium.net/go/maulogger/v2"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/types"
"maunium.net/go/mautrix/id"
)

View File

@ -6,13 +6,13 @@ import (
"regexp"
"strings"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
skypeExt "github.com/0ranki/matrix-skype/skype-ext"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/format"
"maunium.net/go/mautrix/id"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/types"
)
var italicRegex = regexp.MustCompile("([\\s>~*]|^)_(.+?)_([^a-zA-Z\\d]|$)")
@ -81,8 +81,7 @@ func NewFormatter(bridge *Bridge) *Formatter {
return fmt.Sprintf("<code>%s</code>", str)
},
}
formatter.waReplFuncText = map[*regexp.Regexp]func(string) string{
}
formatter.waReplFuncText = map[*regexp.Regexp]func(string) string{}
return formatter
}

View File

@ -1,8 +1,8 @@
package main
import (
"github.com/kelaresg/matrix-skype/database"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/database"
"github.com/0ranki/matrix-skype/types"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/format"
"reflect"

35
go.mod
View File

@ -1,13 +1,13 @@
module github.com/kelaresg/matrix-skype
module github.com/0ranki/matrix-skype
go 1.14
go 1.22
require (
github.com/gabriel-vasile/mimetype v1.1.2
github.com/gorilla/websocket v1.4.2
github.com/kelaresg/go-skypeapi v0.1.2-0.20210813144457-5bc29092a74e
github.com/lib/pq v1.9.0
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/mattn/go-sqlite3 v1.14.22
github.com/pkg/errors v0.9.1
gopkg.in/yaml.v2 v2.4.0
maunium.net/go/mauflag v1.0.0
@ -15,4 +15,33 @@ require (
maunium.net/go/mautrix v0.10.3
)
require (
github.com/PuerkitoBio/goquery v1.5.1 // indirect
github.com/andybalholm/cascadia v1.1.0 // indirect
github.com/btcsuite/btcutil v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/gogf/gf v1.13.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/spf13/viper v1.7.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tidwall/gjson v1.10.2 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tidwall/sjson v1.2.3 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20211020060615-d418f374d309 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
)
replace maunium.net/go/mautrix => github.com/pidongqianqian/mautrix-go v0.10.4-0.20211208080648-321c4f849adb

8
go.sum
View File

@ -40,7 +40,6 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
@ -64,7 +63,6 @@ github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogf/gf v1.13.0 h1:URnD1CPVAuypmNAUveleraOA9CHRKHdvrn8D67uvKu0=
@ -79,7 +77,6 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@ -100,7 +97,6 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gqcn/structs v1.1.1 h1:cyzGRwfmn3d1d54fwW3KUNyG9QxR0ldIeqwFGeBt638=
github.com/gqcn/structs v1.1.1/go.mod h1:/aBhTBSsKQ2Ec9pbnYdGphtdWXHFn4KrCL0fXM/Adok=
github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf h1:wIOAyJMMen0ELGiFzlmqxdcV1yGbkyHBAB6PolcNbLA=
github.com/grokify/html-strip-tags-go v0.0.0-20190921062105-daaa06bf1aaf/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
@ -153,9 +149,10 @@ github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzR
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@ -172,7 +169,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

View File

@ -17,10 +17,10 @@ import (
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
"github.com/kelaresg/matrix-skype/config"
"github.com/kelaresg/matrix-skype/database"
"github.com/kelaresg/matrix-skype/database/upgrades"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/config"
"github.com/0ranki/matrix-skype/database"
"github.com/0ranki/matrix-skype/database/upgrades"
"github.com/0ranki/matrix-skype/types"
)
var (

View File

@ -6,8 +6,8 @@ import (
"strings"
"time"
"github.com/0ranki/matrix-skype/database"
skype "github.com/kelaresg/go-skypeapi"
"github.com/kelaresg/matrix-skype/database"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/patch"

View File

@ -23,8 +23,8 @@ import (
"sync"
"time"
skypeExt "github.com/0ranki/matrix-skype/skype-ext"
skype "github.com/kelaresg/go-skypeapi"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
"github.com/pkg/errors"
log "maunium.net/go/maulogger/v2"
@ -36,8 +36,8 @@ import (
"maunium.net/go/mautrix/id"
"maunium.net/go/mautrix/pushrules"
"github.com/kelaresg/matrix-skype/database"
"github.com/kelaresg/matrix-skype/types"
"github.com/0ranki/matrix-skype/database"
"github.com/0ranki/matrix-skype/types"
)
func (bridge *Bridge) GetPortalByMXID(mxid id.RoomID) *Portal {
@ -614,7 +614,7 @@ func (portal *Portal) userMXIDAction(user *User, fn func(mxid id.UserID)) {
}
func (portal *Portal) ensureMXIDInvited(mxid id.UserID) {
portal.log.Debugfln("ensureMXIDInvited portal.MXID %s: %s", portal.MXID, mxid);
portal.log.Debugfln("ensureMXIDInvited portal.MXID %s: %s", portal.MXID, mxid)
err := portal.MainIntent().EnsureInvited(portal.MXID, mxid)
if err != nil {
portal.log.Warnfln("Failed to ensure %s is invited to %s: %v", mxid, portal.MXID, err)
@ -1152,7 +1152,7 @@ func (portal *Portal) CreateMatrixRoom(user *User) error {
portal.Name = portalName
} else {
portal.Name = metadata.Name
if (user.currentCreateRoomName == portal.Name && portal.Name != "") {
if user.currentCreateRoomName == portal.Name && portal.Name != "" {
return errors.New("It looks like a room is being created in the matrix using command 'create', so there is no need to create a new room here.")
}
}

View File

@ -2,21 +2,21 @@ package main
import (
"fmt"
skypeExt "github.com/0ranki/matrix-skype/skype-ext"
skype "github.com/kelaresg/go-skypeapi"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
"net/http"
"regexp"
"sync"
"strings"
"sync"
log "maunium.net/go/maulogger/v2"
"maunium.net/go/mautrix/appservice"
"maunium.net/go/mautrix/id"
"github.com/kelaresg/matrix-skype/database"
"github.com/kelaresg/matrix-skype/types"
//"github.com/kelaresg/matrix-skype/whatsapp-ext"
"github.com/0ranki/matrix-skype/database"
"github.com/0ranki/matrix-skype/types"
//"github.com/0ranki/matrix-skype/whatsapp-ext"
)
func (bridge *Bridge) ParsePuppetMXID(mxid id.UserID) (types.SkypeID, bool) {

10
user.go
View File

@ -7,8 +7,8 @@ import (
"fmt"
"sort"
skypeExt "github.com/0ranki/matrix-skype/skype-ext"
skype "github.com/kelaresg/go-skypeapi"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
"maunium.net/go/mautrix/patch"
//"strconv"
@ -25,9 +25,9 @@ import (
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
"github.com/kelaresg/matrix-skype/database"
"github.com/kelaresg/matrix-skype/types"
//"github.com/kelaresg/matrix-skype/whatsapp-ext"
"github.com/0ranki/matrix-skype/database"
"github.com/0ranki/matrix-skype/types"
//"github.com/0ranki/matrix-skype/whatsapp-ext"
)
type User struct {
@ -657,7 +657,7 @@ func (user *User) syncPuppets(contacts map[string]skype.Contact, toHomeserver bo
user.log.Infoln("Syncing puppet info from contacts", personId, skypeExt.NewUserSuffix)
if strings.HasSuffix(personId, skypeExt.NewUserSuffix) {
puppet := user.bridge.GetPuppetByJID(personId)
if (!toHomeserver) {
if !toHomeserver {
puppet.Sync(user, contact)
}
matrixContacts = append(matrixContacts, string(puppet.MXID))