diff options
Diffstat (limited to 'appservice/db.go')
-rw-r--r-- | appservice/db.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/appservice/db.go b/appservice/db.go index 6c215d4..512e7b5 100644 --- a/appservice/db.go +++ b/appservice/db.go @@ -3,14 +3,14 @@ package appservice import ( "fmt" - log "github.com/sirupsen/logrus" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/postgres" _ "github.com/jinzhu/gorm/dialects/sqlite" + log "github.com/sirupsen/logrus" - "git.deuxfleurs.fr/Deuxfleurs/easybridge/mxlib" "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" + "git.deuxfleurs.fr/Deuxfleurs/easybridge/mxlib" ) var db *gorm.DB @@ -40,7 +40,7 @@ type DbUserMap struct { gorm.Model Protocol string - UserID connector.UserID + UserID connector.UserID MxUserID string `gorm:"index:mxuserid"` } @@ -63,8 +63,8 @@ type DbPmRoomMap struct { gorm.Model // User id and account name of the local end viewed on Matrix - MxUserID string - Protocol string + MxUserID string + Protocol string AccountName string // User id to reach them @@ -83,7 +83,7 @@ func dbGetMxRoom(protocol string, roomId connector.RoomID) (string, error) { // If not create it must_create := db.First(&room, DbRoomMap{ Protocol: protocol, - RoomID: roomId, + RoomID: roomId, }).RecordNotFound() if must_create { alias := roomAlias(protocol, roomId) @@ -103,7 +103,7 @@ func dbGetMxRoom(protocol string, roomId connector.RoomID) (string, error) { room = DbRoomMap{ Protocol: protocol, - RoomID: roomId, + RoomID: roomId, MxRoomID: mx_room_id, } db.Create(&room) @@ -117,10 +117,10 @@ func dbGetMxPmRoom(protocol string, them connector.UserID, themMxId string, usMx var room DbPmRoomMap must_create := db.First(&room, DbPmRoomMap{ - MxUserID: usMxId, - Protocol: protocol, + MxUserID: usMxId, + Protocol: protocol, AccountName: usAccount, - UserID: them, + UserID: them, }).RecordNotFound() if must_create { name := fmt.Sprintf("%s (%s)", them, protocol) @@ -138,11 +138,11 @@ func dbGetMxPmRoom(protocol string, them connector.UserID, themMxId string, usMx } room = DbPmRoomMap{ - MxUserID: usMxId, - Protocol: protocol, + MxUserID: usMxId, + Protocol: protocol, AccountName: usAccount, - UserID: them, - MxRoomID: mx_room_id, + UserID: them, + MxRoomID: mx_room_id, } db.Create(&room) } @@ -156,7 +156,7 @@ func dbGetMxUser(protocol string, userId connector.UserID) (string, error) { must_create := db.First(&user, DbUserMap{ Protocol: protocol, - UserID: userId, + UserID: userId, }).RecordNotFound() if must_create { username := userMxId(protocol, userId) @@ -174,7 +174,7 @@ func dbGetMxUser(protocol string, userId connector.UserID) (string, error) { user = DbUserMap{ Protocol: protocol, - UserID: userId, + UserID: userId, MxUserID: mxid, } db.Create(&user) |