52 Commits

Author SHA1 Message Date
Huong Nguyen
9a517653b1
MDL-78129 communication_matrix: Remove Behat test
This change requires a change in the mock server which we don't have
    time to do before Beta. This will be done in the coming days and this
    commit content reverted.
This one will be re-introduced in MDL-79460
2023-09-22 13:17:21 +07:00
Huong Nguyen
436e522cd8
MDL-78129 communication_matrix: Skip Behat test
This change requires a change in the mock server which we don't have
time to do before Beta. This will be done in the coming days and this
commit content reverted.
2023-09-22 11:42:28 +07:00
Huong Nguyen
bd323aede7
Merge branch 'MDL-78129-master' of https://github.com/andrewnicols/moodle 2023-09-22 10:29:54 +07:00
Andrew Nicols
84cfc8beeb
MDL-78129 communication: Fix all phpcs isuses
This is a brand new subsystem, plugin-type, and plugin. They are written
from the ground up by us. They should not contain any coding style
violations.
2023-09-22 11:08:04 +08:00
Andrew Nicols
2a096dc5ad
MDL-78129 communication_matrix: Skip unit test
This change requires a change in the mock server which we don't have
time to do before Beta. This will be done in the coming days and this
commit content reverted.
2023-09-22 10:51:50 +08:00
Andrew Nicols
07e0094f8c
MDL-78129 communication_matrix: Persist any user with a non-moodle power level 2023-09-22 10:44:04 +08:00
Andrew Nicols
01a3461bbb
MDL-78129 communication_matrix: Simplify power level setting
This change introduces a new API call to fetch the current power levels.

The result of this are used to fetch current admin users so as not to
remove them.

The update of existing users is simplified to only set users who do not
have the default level.
2023-09-22 10:44:04 +08:00
Andrew Nicols
eb991355fe
MDL-78129 communication_matrix: Stop marking users as synced
No need to sync users for role changes.

Power level changes do not need to happen after being added to a room.
They can happen in any order and persist after a user is removed.
2023-09-22 10:44:04 +08:00
Andrew Nicols
01679678cf
MDL-78129 communication_matrix: Coding style fixes 2023-09-22 10:44:03 +08:00
Andrew Nicols
2dc30d662e
MDL-78129 communication_matrix: Tidy up API calls 2023-09-22 10:44:03 +08:00
Safat
e9743431a6
MDL-78129 communication_matrix: Add support for matrix power level 2023-09-22 10:44:02 +08:00
Andrew Nicols
148e779651
Merge branch 'MDL-78649-master' of https://github.com/meirzamoodle/moodle 2023-09-21 22:25:14 +08:00
Safat
3e47253787
MDL-78129 core_communication: Add update membership api 2023-09-21 13:28:20 +08:00
David Woloszyn
24cdc908ba MDL-78798 core_communication: Corrected outdated versions and references 2023-09-11 11:16:22 +10:00
meirzamoodle
bebd10c5a5 MDL-78649 core_communication: Clarify form provider method name 2023-09-08 16:50:54 +07:00
meirzamoodle
129d8afa39 MDL-78649 core_communication: Fix missing provider form fields types 2023-09-08 16:50:50 +07:00
Huong Nguyen
bd372a63d2
Merge branch 'MDL-78619-master' of https://github.com/mickhawkins/moodle 2023-09-07 15:19:18 +07:00
Michael Hawkins
d0c7834050
MDL-78619 communication_matrix: Unit test fix 2023-08-29 19:55:34 +08:00
Michael Hawkins
a3fa3e3fc1
MDL-78619 communication_customlink: Implement custom link provider 2023-08-27 23:10:16 +08:00
Michael Hawkins
bfbb314e2f
MDL-78619 communication: De-couple room & user management and API fix
Management fix: Although rooms and room users are implemented as
separate provider interfaces, there were still assumptions that
adding/removing rooms would require user handling. Where room_provider
was implemented but room_user_provider was not, that would then result
in either unnecessary ad-hoc tasks, or tasks failing with errors. Now,
checks are in place to avoid these scenarios.

API fix: Previously save_form_data() was being called on the old
provider instead of the newly enabled one, so when switching between
providers the settings would not be correctly applied and the provider
may not function. Now, the object is reloaded and the data is saved correctly.
2023-08-27 23:06:22 +08:00
Andrew Nicols
e7b5d97c9a
MDL-78747 communication_matrix: Correct table name
Note: This feature is currently master-only, and alpha. I have therefore
decided not to migrate data and am just dumping and re-crating the
table.
2023-08-26 14:46:53 +08:00
Andrew Nicols
d38c3dfc8e
MDL-77917 communication_matrix: Topic must not be null
The Matrix space/room topic must always be a string. We should normalise
this on the way out of the API.
2023-08-24 23:19:38 +08:00
Andrew Nicols
6d1bd4787f
MDL-77917 communication_matrix: Use v1.7 upload content API
Version 1.7 of the Matrix API adds a new endpoint for uploading media.
`_matrix/media/v1/create` and adds a new path parameter to the existing
`_matrix/media/v3/upload` endpoint.
2023-08-24 11:59:30 +08:00
Andrew Nicols
914686bc5e
MDL-77917 communication_matrix: Support server API versions
This commit brings in support for multiple versions of the Matrix
specification.

A Matrix server is compromised of a number of individually versioned API
endpoints, for example:

    /_matrix/client/v3/createRoom
    /_matrix/client/v3/rooms/:roomid/joined_members
    /_matrix/media/v1/create

The combination of a large number of these individually versioned
endpoints forms a Matrix Specification version.

For example:

* the /_matrix/media/v1/create endpoint was created for version 1.7 of the
  specification, and does not exist in earlier versions.
* in the future a new behaviour or parameter may be created for the
  `createRoom` endpoint and a new endpoint created at:

    /_matrix/client/v4/createRoom

A single server can support multiple versions of the Matrix
specification. The server declares the versions of the specification
that it supports using a non-versioned endpoint at
`/_matrix/client/versions`.

As a Matrix client, Moodle should:
* query the server version endpoint
* determine the combination of mutually supported Matrix specification
  versions
* create a client instance of the highest-supported version of the
  specification.

For example, if Moodle (Matrix client) and a remote server have the
following support:

```
Moodle:      1.1  1.2  1.3  1.4  1.5  1.6  1.7
Server:  r0  1.1  1.2  1.3  1.4  1.5  1.6
```

The versions in common are 1.1 through 1.6, and version 1.6 would be
chosen.

To avoid duplication and allow for support of future features more
easily, the Moodle client is written as:
* a set of classes named `v1p1` through `v1p7` (currently) which extend
  the `matrix_client` abstract class; and
* a set if PHP traits which provide the implementation for individual
  versioned endpoints.

Each client version then imports any relevant traits which are present
in that version of the Matrix Specification. For example versions 1.1 to
1.6 do _not_ have the `/_matrix/media/v1/create` endpoint so they do not
import this trait. This trait was introduced in version 1.7, so the
trait is included from that version onwards.

In the future, if an endpoint is created which conflicts with an
existing endpoint, then it would be easy to create a new client version
which uses the existing common traits, and adds the new trait.

Each endpoint is written using a `command` class which extends the
Guzzle implementation of the PSR-7 Request interface. This command
class adds support for easy creation of:
* path parameters within the URI
* query parameters
* body parameters

This is done to avoid complex patterns of Request creation which are
repeated for every client endpoint.
2023-08-24 11:59:25 +08:00
Huong Nguyen
aeeb1653c0
Merge branch 'MDL-78553-master' of https://github.com/davewoloszyn/moodle 2023-08-03 09:44:24 +07:00
David Woloszyn
317251a978 MDL-78553 core_communication: Move settings to their own page 2023-08-03 12:36:04 +10:00
David Woloszyn
5aea409a87 MDL-78553 behat: Add disable communication helper trait 2023-08-03 10:20:23 +10:00
Sara Arjona
c1d805a676
Merge branch 'MDL-78738-master' of https://github.com/andrewnicols/moodle 2023-08-01 16:24:42 +02:00
Andrew Nicols
8b97071c94
MDL-78738 core_communication: Set avatar from a stored_file
We should always use a stored_file instance to set the avatar, and never
a data uri. Especially where the datauri is from Moodle itself.

This change requires a number of changes in associated locations.

I am not adding this change to any upgrade notes as this is a
master-only feature.

Note: I have removed some tests and will not consider fixing them
because I will be entirely removing that test file in a subsequent issue
(MDL-77917).
2023-08-01 19:50:14 +08:00
Andrew Nicols
f067d6004f
MDL-78723 communication_matrix: Address issues with user manager
This commit addresses a number of issues with the Matrix user manager.
These are, unfortunately, tough to break out into smaller commits.

The following issues are addressed:

Matrix usernames should be kept intact in the profile field. Prior to
this change, usernames were mangled and the hostname removed entirely.
Instead the hostname was added back when it is used. This approach is
not suited to a case where a user inserts their own matrix username on a
federated server.

Unit tests should have the minimum of requirements and dependencies.
Prior to this change, unit tests were setting up an entire mock system
which was completely unnecessary. These unit tests should only test the
static methods that they claim to test, not the entire communication
subsystem, matrix API, matrix client, processors, and providers.

Matrix host names should not be curtailed. Prior to this change the
hostname of the matrix server was modified if it contained any .
characters. For example, the following changes were previously made:

| hostname           | before  | after              |
| ------------------ | ------- | ------------------ |
| matrix.example.com | matrix  | matrix.example.com |
| www.example.com    | example | example.com        |

I believe that the original intent was to strip the www from the front,
but this is not documented anywhere that I have found. In any case, the
username should be the completed and fully-qualified username.

Many of the methods were poorly named:
- `set_qualified_matrix_user_id` is actually a userid formatter.
  This has been replaced with `get_formatted_matrix_userid`.
- `set_matrix_home_server` is actually a hostname formatter.
  This has been replaced with `get_formatted_matrix_home_server`.
- `add_user_matrix_id_to_moodle` sets the matrix userid for a moodle
  user, it does not add more than one.
  This has been replaced with `set_matrix_userid_in_moodle`.

The `set_qualified_matrix_user_id` method was silently returning with a
false value if the profile custom field did not exist, but the
`get_matrixid_from_moodle` method was creating the profile custom field
in the same situation. These have been swapped so a set operation will
create the field if it does not exist, but a get operation will not.
2023-07-24 10:35:52 +08:00
Andrew Nicols
6d8db08c35
Merge branch 'MDL-78567-master' of https://github.com/stevandoMoodle/moodle 2023-07-13 16:49:59 +02:00
Stevani Andolo
68e60b9bab MDL-78567 communication_matrix: Fixed plugin version for upgrade 2023-06-30 11:21:17 +08:00
David Woloszyn
616c6a0809 MDL-77356 communication_matrix: Update avatar if different 2023-06-30 10:38:40 +10:00
David Woloszyn
162c9fdd66 MDL-77356 communication: Update avatar filename and avatar synced 2023-06-30 10:38:40 +10:00
Andrew Nicols
54f2722a7b
Merge branch 'MDL-78523-master' of https://github.com/safatshahin/moodle 2023-06-24 23:39:37 +08:00
Safat
42f704ac11 MDL-78523 communication_matrix: Behat coverage for matrix safe disable 2023-06-22 12:19:44 +10:00
Safat
d785ff6f57 MDL-78523 core_communication: Safe disable of communication plugins 2023-06-22 12:19:44 +10:00
Safat
3f48306385 MDL-76704 core_communication: Default setting for communication provider 2023-06-21 14:46:32 +10:00
Safat
7e91f77541 MDL-77357 communication_matrix: Add plugin savepoint 2023-06-08 14:18:25 +10:00
Safat
17e4523382 MDL-77357 communication_matrix: Test fix for course banner notification 2023-06-06 17:08:51 +10:00
Safat
5fc1dedeae MDL-77357 communication_matrix: Implement dynamic form fields 2023-06-01 00:42:53 +10:00
Safat
04b7c496f0 MDL-77357 core_communication: Add api for provider form fields 2023-06-01 00:39:03 +10:00
David Woloszyn
81414b527a MDL-77252 course: Fixed failing communication room status test 2023-05-26 11:55:23 +10:00
Andrew Nicols
d895574c9a
Merge branch 'MDL-77252-master' of https://github.com/davewoloszyn/moodle 2023-05-25 10:49:30 +08:00
Eloy Lafuente (stronk7)
b171f57cd5
MDL-77576 matrix: Bump version to today
All master versions need to be > than the previous
release (4.2) versions. To avoid overlapping to happen.
2023-05-19 11:20:29 +02:00
David Woloszyn
5bad9bd064 MDL-77252 course: Show notification depending on room status 2023-05-17 10:22:24 +10:00
David Woloszyn
d38cc920c5 MDL-77252 core_communication: Get room status and notifications 2023-05-17 10:06:11 +10:00
Safat
019f74f8b6 MDL-77576 core_communication: Implement privacy api 2023-05-11 13:35:17 +10:00
Safat
9a060a6d8d MDL-77576 communication_matrix: Create Matrix plugin
This commit will implement a matrix communication plugin
to integrate matrix services with core communication.

Originally implemented as MDL-76701, MDL-76702, MDL-77357,
MDL-76705, MDL-77473 and  MDL-76708.

Co-Authored-By: Stevani Andolo <stevani.andolo@moodle.com>
Co-Authored-By: David Woloszyn <david.woloszyn@moodle.com>
Co-Authored-By: Safat Shahin <safat.shahin@moodle.com>
2023-05-11 13:35:16 +10:00
Safat
ca1e5d0beb MDL-77576 core_communication: Add core communication api
This commit will implement the base api for core
communication. This will include the room creation,
room membership, room access url and all associated
api and related interfaces.

Originally implemented as MDL-76702, MDL-76703 and MDL-76705.

Co-Authored-By: David Woloszyn <david.woloszyn@moodle.com>
Co-Authored-By: Safat Shahin <safat.shahin@moodle.com>
2023-05-11 13:35:16 +10:00