aboutsummaryrefslogtreecommitdiff
path: root/db.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-26 16:30:10 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-26 16:30:10 +0100
commitf3f1b8d981d818b38713fe84deb206720b0fcb10 (patch)
tree7fd0f5d3e71b3553a4c57db71cb01d2426075967 /db.go
parent67c7f7361d63a282788f159494a6f43172c8806a (diff)
downloadeasybridge-f3f1b8d981d818b38713fe84deb206720b0fcb10.tar.gz
easybridge-f3f1b8d981d818b38713fe84deb206720b0fcb10.zip
Room autorejoin
Diffstat (limited to 'db.go')
-rw-r--r--db.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/db.go b/db.go
index fe3d1e3..602bd1f 100644
--- a/db.go
+++ b/db.go
@@ -36,6 +36,9 @@ func InitDb() error {
db.AutoMigrate(&DbPmRoomMap{})
db.Model(&DbPmRoomMap{}).AddIndex("idx_protocol_user_account_user", "protocol", "user_id", "mx_user_id", "account_name")
+ db.AutoMigrate(&DbJoinedRoom{})
+ db.Model(&DbJoinedRoom{}).AddIndex("idx_user_protocol_account", "mx_user_id", "protocol", "account_name")
+
return nil
}
@@ -86,6 +89,19 @@ type DbPmRoomMap struct {
MxRoomID string `gorm:"index:mxroomoid"`
}
+// List of joined channels to be re-joined on reconnect
+type DbJoinedRoom struct {
+ gorm.Model
+
+ // User id and account name
+ MxUserID string
+ Protocol string
+ AccountName string
+
+ // Room ID
+ RoomID connector.RoomID
+}
+
// ---- Simple locking mechanism
var dbLocks [256]sync.Mutex