matrix: end-to-end encryption by default

Existing chats will remain unencrypted but new ones will be.
This commit is contained in:
Harvey Tindall
2021-07-13 19:02:16 +01:00
parent 30198fab87
commit 833d02b032
10 changed files with 221 additions and 53 deletions

12
api.go
View File

@@ -2571,18 +2571,20 @@ func (app *appContext) MatrixConnect(gc *gin.Context) {
if app.storage.matrix == nil {
app.storage.matrix = map[string]MatrixUser{}
}
roomID, err := app.matrix.CreateRoom(req.UserID)
roomID, encrypted, err := app.matrix.CreateRoom(req.UserID)
if err != nil {
app.err.Printf("Matrix: Failed to create room: %v", err)
respondBool(500, false, gc)
return
}
app.storage.matrix[req.JellyfinID] = MatrixUser{
UserID: req.UserID,
RoomID: string(roomID),
Lang: "en-us",
Contact: true,
UserID: req.UserID,
RoomID: string(roomID),
Lang: "en-us",
Contact: true,
Encrypted: encrypted,
}
app.matrix.isEncrypted[roomID] = encrypted
if err := app.storage.storeMatrixUsers(); err != nil {
app.err.Printf("Failed to store Matrix users: %v", err)
respondBool(500, false, gc)