summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabe Kangas <gabek@real-ity.com>2022-01-18 15:38:23 -0800
committerGabe Kangas <gabek@real-ity.com>2022-01-18 15:38:23 -0800
commit3b0dafba9a76c307fde5d42b97c293a05d90bc16 (patch)
tree2625a14fb5b18f0c748ae6760d4ea0ed019bc423
parentcf24a6aa81cb81d2c6f153d862e7e42747d67430 (diff)
Return error in API response. Return all fields in message+user query
-rw-r--r--controllers/admin/chat.go6
-rw-r--r--core/chat/persistence.go6
-rw-r--r--router/router.go1
3 files changed, 9 insertions, 4 deletions
diff --git a/controllers/admin/chat.go b/controllers/admin/chat.go
index 8a66c5a9f..91bdba132 100644
--- a/controllers/admin/chat.go
+++ b/controllers/admin/chat.go
@@ -68,13 +68,15 @@ func UpdateUserEnabled(w http.ResponseWriter, r *http.Request) {
if err := decoder.Decode(&request); err != nil {
log.Errorln(err)
- controllers.WriteSimpleResponse(w, false, "")
+ controllers.WriteSimpleResponse(w, false, err.Error())
return
}
// Disable/enable the user
if err := user.SetEnabled(request.UserID, request.Enabled); err != nil {
log.Errorln("error changing user enabled status", err)
+ controllers.WriteSimpleResponse(w, false, err.Error())
+ return
}
// Hide/show the user's chat messages if disabling.
@@ -82,6 +84,8 @@ func UpdateUserEnabled(w http.ResponseWriter, r *http.Request) {
if !request.Enabled {
if err := chat.SetMessageVisibilityForUserID(request.UserID, request.Enabled); err != nil {
log.Errorln("error changing user messages visibility", err)
+ controllers.WriteSimpleResponse(w, false, err.Error())
+ return
}
}
diff --git a/core/chat/persistence.go b/core/chat/persistence.go
index 17bb7796e..315a3de5b 100644
--- a/core/chat/persistence.go
+++ b/core/chat/persistence.go
@@ -296,9 +296,9 @@ func SetMessageVisibilityForUserID(userID string, visible bool) error {
_historyCache = nil
}()
- // Get a list of IDs from this user within the 5hr window to send to the connected clients to hide
+ // Get a list of IDs to send to the connected clients to hide
ids := make([]string, 0)
- query := fmt.Sprintf("SELECT messages.id, user_id, body, eventType, hidden_at, timestamp, display_name, display_color, created_at, disabled_at, previous_names, namechanged_at FROM messages INNER JOIN users ON messages.user_id = users.id WHERE user_id IS '%s'", userID)
+ query := fmt.Sprintf("SELECT messages.id, user_id, body, title, subtitle, image, link, eventType, hidden_at, timestamp, display_name, display_color, created_at, disabled_at, previous_names, namechanged_at, scopes FROM messages INNER JOIN users ON messages.user_id = users.id WHERE user_id IS '%s'", userID)
messages := getChat(query)
if len(messages) == 0 {
@@ -306,7 +306,7 @@ func SetMessageVisibilityForUserID(userID string, visible bool) error {
}
for _, message := range messages {
- ids = append(ids, message.(events.Event).ID)
+ ids = append(ids, message.(events.UserMessageEvent).ID)
}
// Tell the clients to hide/show these messages.
diff --git a/router/router.go b/router/router.go
index 6b3c32f49..3928675d1 100644
--- a/router/router.go
+++ b/router/router.go
@@ -279,6 +279,7 @@ func Start() error {
// Enable/disable a user
http.HandleFunc("/api/chat/users/setenabled", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateUserEnabled))
+
// Configure Federation features
// enable/disable federation features