You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/apis.md
+4
Original file line number
Diff line number
Diff line change
@@ -92,6 +92,10 @@ The [Check API](./apis/subsystems/check/index.md) allows you to add security, pe
92
92
93
93
The [Comment API](https://docs.moodle.org/dev/Comment_API) allows you to save and retrieve user comments, so that you can easily add commenting to any of your code.
94
94
95
+
### Communication API (communication)
96
+
97
+
The [Communication API](./apis/subsystems/communication/index.md) provides access to the messaging system and other communication providers (such as Matrix).
98
+
95
99
### Competency API (competency)
96
100
97
101
The [Competency API](https://docs.moodle.org/dev/Competency_API) allows you to list and add evidence of competencies to learning plans, learning plan templates, frameworks, courses and activities.
Copy file name to clipboardexpand all lines: docs/apis/plugintypes/communication/index.md
+36-33
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
---
2
-
title: Communication
2
+
title: Communication plugin
3
3
tags:
4
-
- communication
5
-
- provider
6
-
- Communication provider
7
-
- Communication room
8
-
- Communication service
9
-
- Chat
4
+
- communication
5
+
- provider
6
+
- Communication provider
7
+
- Communication room
8
+
- Communication service
9
+
- Chat
10
10
documentationDraft: true
11
11
---
12
12
@@ -58,30 +58,15 @@ you like. These are feature classes which will be defined from the communication
58
58
59
59
:::
60
60
61
-
## Creating a new plugin
62
-
63
-
:::info
64
-
65
-
TBA after implementing MDL-76796
66
-
67
-
:::
68
-
69
-
### Generating the plugin skeleton
70
-
71
-
:::info
72
-
73
-
TBA after implementing MDL-76796
74
-
75
-
:::
76
-
77
61
## Key files
78
62
79
63
There are a number of key files within the plugin, described below.
80
64
81
65
### communication_feature.php
82
66
83
-
Each plugin must implement this class and should have the exact class name. This part is important for the core communication api.
84
-
The core communication api will pick the features and actions from this class. This class should implement the interfaces it supports.
67
+
Each plugin must implement this class and should have the exact class name. The core communication api will pick the features and actions from this class. There is no strict rule
68
+
on which interfaces should be implemented, plugins can choose which features they support and implement accordingly. Exception is the `communication_provider` interface which
69
+
is mandatory for all the plugins. Check below for more details on the interfaces.
85
70
86
71
```php
87
72
class communication_feature implements
@@ -100,24 +85,26 @@ class communication_feature implements
100
85
### communication_provider
101
86
102
87
This is the base communication provider interface. This interface should be used to declare the support for the instantiation method for communication providers.
103
-
Every provider plugin must implement this interface. This interface will have the following methods.
88
+
Every provider plugin must implement this interface as a bare minimum. This interface will have the following methods.
104
89
105
90
#### load_for_instance()
106
91
107
-
This method will have the base communication processor object which will allow loading the communication provider for the communication api.
92
+
This method will have the base communication processor(core_communication\processor) object which will allow loading the communication provider for the communication api.
108
93
109
94
### user_provider
110
95
111
-
This is the base user provider interface. This interface should be used to declare the support for the for user provider creation and management.
112
-
Every provider plugin must implement this interface if user creation is required. This interface will have the following methods.
96
+
This is the user provider interface. This interface should be used to declare the support for the for user creation for a provider. For example, Matrix allows creation of users
97
+
via API and the `communication_matrix` plugin can support the creation of users in Matrix, in that case, `communication_matrix` plugin should implement this interface. Some APIs might
98
+
not need to create user as they might have been created in a different way, in that case this interface can be excluded. This interface will have the following methods.
113
99
114
100
#### create_members()
115
101
116
-
All the necessary actions to create members for the room should live here. Some APIs might not need to create user as they might have been created in a different way.
102
+
All the necessary code and API calls to create members for the communication room should live here.
117
103
118
104
### room_chat_provider
119
105
120
-
This interface will define the features for creating a room. Let's look at the methods of this interface to get a better idea.
106
+
This interface will define the features for creating a room. For example, if a communication provider allows creating a room via API, this interface should be implemented.
107
+
Let's look at the methods of this interface to get a better idea.
121
108
122
109
#### create_chat_room()
123
110
@@ -134,20 +121,36 @@ value should be returned to indicate if the room is deleted or something went wr
134
121
135
122
#### generate_room_url()
136
123
137
-
Generate a room url according to the room information, web client url or any other required information.
124
+
Generate a room url according to the room information, web client url or any other required information. This is an important one to allow users access the room from the UI.
125
+
Course has an icon to access the room if a room is created for the course, this method will be used to generate the url for the room.
138
126
139
127
### room_user_provider
140
128
141
-
This interface will define the features for adding members to the room or removing members from the room. Let's look at the methods of this class to get a better idea.
129
+
This interface will define the features for adding/removing/updating members to the room. Room members should be added when a user is enrolled or a role changes. If a provider
130
+
allows addition of users to a room via API, this interface should be implemented. Let's look at the methods of this class to get a better idea.
142
131
143
132
#### add_members_to_room()
144
133
145
134
All the necessary actions to add members to a room should live here. The array of user ids must be passed here.
146
135
136
+
#### update_room_membership()
137
+
138
+
Updating the membership might be necessary in some cases where a user is capability changed, this method will come into play in those cases.
139
+
147
140
#### remove_members_from_room()
148
141
149
142
All the necessary actions to remove members from a room should live here. The array of user ids must be passed here.
150
143
144
+
### synchronise_provider
145
+
146
+
Communication API has a scheduled task `core_communication\task\synchronise_providers_task` which will synchronise the data from the communication provider to the current Moodle
147
+
instance. For example, it can compare the users in the communication room and users enrolled in a course and add/remove users accordingly. The scheduled task runs and adds an
148
+
ad-hoc task for each instance where the provider implements this interface. This feature will help keep the data on-sync between the provider and Moodle.
149
+
150
+
#### synchronise_room_members()
151
+
152
+
All the necessary code to synchronise the room members should live here.
153
+
151
154
:::info
152
155
153
156
For a real plugin example, please look at the [Matrix plugin](https://github.com/moodle/moodle/tree/master/communication/provider/matrix).
0 commit comments