diff options
Diffstat (limited to 'util.go')
-rw-r--r-- | util.go | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -20,7 +20,25 @@ func ezbrMxId() string { } func ezbrSystemRoom(user_mx_id string) (string, error) { - return dbGetMxPmRoom(EASYBRIDGE_SYSTEM_PROTOCOL, UserID("Easybridge"), ezbrMxId(), user_mx_id, "easybridge") + mx_room_id, err := dbGetMxPmRoom(EASYBRIDGE_SYSTEM_PROTOCOL, UserID("Easybridge"), ezbrMxId(), user_mx_id, "easybridge") + if err != nil { + return "", err + } + + widget_kv_key := "ezbr_widget_on:" + mx_room_id + if config.WebURL != "" && dbKvTestAndSet(widget_kv_key, "yes") { + widget := map[string]interface{}{ + "type": "m.easybridge", + "url": config.WebURL, + "name": "Easybridge account configuration dashboard", + } + err = mx.PutStateAs(mx_room_id, "im.vector.modular.widgets", "ezbr_widget", widget, ezbrMxId()) + if err != nil { + dbKvPut(widget_kv_key, "") + } + } + + return mx_room_id, nil } func ezbrSystemSend(user_mx_id string, msg string) { |