# HG changeset patch # User Jonas Schäfer # Date 1611246634 -3600 # Node ID 29b7f445aec59a72782c950f0ffc7e4b7388861b # Parent e0c8d866d58cae843f180308f06195c27abcad80 mod_http_admin_api: add support for updating groups diff -r e0c8d866d58c -r 29b7f445aec5 mod_http_admin_api/mod_http_admin_api.lua --- a/mod_http_admin_api/mod_http_admin_api.lua Thu Jan 21 16:02:31 2021 +0000 +++ b/mod_http_admin_api/mod_http_admin_api.lua Thu Jan 21 17:30:34 2021 +0100 @@ -437,7 +437,32 @@ elseif not group_memberships:set(group_id, member_name, true) then return 500; end - return 200; + return 204; + end + + local group_id = group:match("^([^/]+)$") + if group_id then + local request = event.request; + if request.headers.content_type ~= json_content_type + or (not request.body or #request.body == 0) then + return 400; + end + + local update = json.decode(event.request.body); + if not update then + return 400; + end + + local group_info = group_info_store:get(group_id); + if not group_info then + return 404; + end + + if update.name then + group_info["name"] = update.name + end + group_info_store:set(group_id, group_info); + return 204; end return 400; end