-
New Feature
-
Resolution: Fixed
-
Major
-
4.2
-
MOODLE_402_STABLE
-
MOODLE_403_STABLE
-
MDL-77357-master -
-
6
-
Team Hedgehog Sprint 2.2, Team Hedgehog 2023 Sprint 1.3, Team Hedgehog 2023 Sprint 1.4, Team Hedgehog 2023 Sprint 2.0, Team Hedgehog 2023 Sprint 2.1, Team Hedgehog 2023 Sprint 2.2
-
Medium
Create a dynamic form fields api for communication plugin so that plugins can define their own form elements in the communication settings when selected. For example, Matrix plugin should be able to allow adding Room topic as a field in the communication settings when matrix is selected.
As POC, implement this api in matrix and update room topic from matrix.
Some important information:
Create Room
Create a new room from scratch:
curl --header "Authorization: Bearer syt_YWRtaW4_MGZMsmjMJocVcXpZbEIV_0V1eZi" \
-XPOST -d '{"name":"newroom","topic":"room made by api","visibility":"public","preset":"public_chat","room_alias_name":"newroom","initial_state":[]}' \
"http://synapse:8008/_Matrix/client/r0/createRoom"
The response is like:
{"room_id":"!bYolbGubJnMDhJiPnz:synapse","room_alias":"#newroom:synapse"}We’ll need to store both the room_id and room_alias in Moodle
A further example that sets up end to end encryption for a room:
curl 'https://synapse:8008/_matrix/client/r0/createRoom' -X POST -H 'Authorization: Bearer syt_YWRtaW4_KXUwoITuowupgGEIGNuK_4MLu3S' -d '{"name":"curl room","topic":"curly topic","preset":"private_chat","visibility":"private","initial_state":\\\{"type":"m.room.encryption","state_key":"","content":{"algorithm":"m.megolm.v1.aes-sha2"}}}'
Documentation specific to this process is here: https://spec.matrix.org/v1.5/client-server-api/#post_matrixclientv3createroom
Update Room
Make changes to the room's details. Most room details can only be changed one at a time. For example changing a room name and topic are two separate API calls.
Changing a room topic:
curl 'https://synapse:8008/_matrix/client/r0/rooms/!IWCtGkszxDkBUrIsGg%3Asynapse/state/m.room.topic/' -X PUT -H 'Authorization: Bearer syt_YWRtaW4_KXUwoITuowupgGEIGNuK_4MLu3S' -d '{"topic":"the topic updated"}'