Skip to content

Conversation

@ArtificialOwl
Copy link
Member

No description provided.

@ArtificialOwl
Copy link
Member Author

Request will be in the form: /ocs/v2.php/apps/circles/admin/<userId>/[...]
The idea is that it will emulate the action from the assigned userId, but keep trace of the admin that generate the request.

As we can see in the screenshot, cult (the admin) emulate the user test3 to create a Circle. test3 is the owner of the Circle, but have been invitedBy the admin cult

image

@ArtificialOwl
Copy link
Member Author

more route will be added, but the main part of the edit is here: allow an admin to manage the app

@ArtificialOwl ArtificialOwl force-pushed the feature/noid/manage-circle-using-ocs-and-admin-account branch from 0caa084 to 37c3c70 Compare June 25, 2021 12:05
@ArtificialOwl ArtificialOwl merged commit ac736b7 into master Jun 25, 2021
@delete-merged-branch delete-merged-branch bot deleted the feature/noid/manage-circle-using-ocs-and-admin-account branch June 25, 2021 12:06
@ArtificialOwl
Copy link
Member Author

/backport to stable22

@ArtificialOwl
Copy link
Member Author

Some examples:

Creating a circle

Creating a circle under the identity of test1:

curl -X POST -u 'admin:password' -H "OCS-ApiRequest: true" "https://cloud.example.net/ocs/v2.php/apps/circles/admin/test1/circles?format=json" -F "name=This is a test"

This will return the information about the freshly generated Circle:

{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 200,
      "message": "OK"
    },
    "data": {
      "id": "s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy",
      "name": "This is a test",
      "displayName": "This is a test",
[...]

The important information here is the id=s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy. We call that singleId of the Circle or CircleId

Adding member to a Circle:

Adding test2 to the generated Circle s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy under the identity of test1:

curl -X POST -u 'admin:password' -H "OCS-ApiRequest: true" `"https://cloud.example.net/ocs/v2.php/apps/circles/admin/test1/circles/s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy/members?format=json" -F "userId=test2" -F "type=1"

This will returns information about the added member:

{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 200,
      "message": "OK"
    },
    "data": {
      "id": "ILi7iNQEPsac2lQbrWIIMf6MFXw7eP6",
      "circleId": "s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy",
      "singleId": "STeIV6mEQiQS2pt6joFhs5GsIlIizpc",
      "userId": "test2",
      "userType": 1,
  [...]

The important information here is the id=ILi7iNQEPsac2lQbrWIIMf6MFXw7eP6. We call that memberId which identify a member.

If you know the singleId of the entity you want to add as member (a user, another circle, a group), you can use it as userId and set type=0 (default value)

Removing a Member:

Removing member ILi7iNQEPsac2lQbrWIIMf6MFXw7eP6 from the generated Circle s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy under the identity of test1:

curl -X DELETE -u 'admin:password' -H "OCS-ApiRequest: true" `"https://cloud.example.net/ocs/v2.php/apps/circles/admin/test1/circles/s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy/members/ILi7iNQEPsac2lQbrWIIMf6MFXw7eP6?format=json"

@ArtificialOwl
Copy link
Member Author

listing members from a Circle:

curl -X GET -u 'admin:password' -H "OCS-ApiRequest: true" `"https://cloud.example.net/ocs/v2.php/apps/circles/admin/test1/circles/s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy/members?format=json"

listing Circles available to a User:

curl -X GET -u 'admin:password' -H "OCS-ApiRequest: true" ``"https://cloud.example.net/ocs/v2.php/apps/circles/admin/test1/circles?format=json"`

Changing the level of a Member:

curl -X PUT -u 'admin:password' -H "OCS-ApiRequest: true" `"https://cloud.example.net/ocs/v2.php/apps/circles/admin/test1/circles/s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy/members/ILi7iNQEPsac2lQbrWIIMf6MFXw7eP6/level?format=json" --data '{"level": "Moderator"}' -H "Content-Type: application/json"

List of available levels: Member, Moderator, Admin, Owner

Change the type/config of a Circle

curl -X PUT -u 'admin:password' -H "OCS-ApiRequest: true" `"https://cloud.example.net/ocs/v2.php/apps/circles/admin/test1/circles/s91CHxlF6Mt5CPpP4N6SRxO2vojVqDy/config" --data '{"value": 88}' -H "Content-Type: application/json"

Note: the value is a bitwise flag, based on those values:

	const CFG_CIRCLE = 0;        // only for code readability. Circle is locked by default.
	const CFG_VISIBLE = 8;           // Visible to everyone, if not visible, people have to know its name to be able to find it
	const CFG_OPEN = 16;             // Circle is open, people can join
	const CFG_INVITE = 32;           // Adding a member generate an invitation that needs to be accepted
	const CFG_REQUEST = 64;          // Request to join Circles needs to be confirmed by a moderator
	const CFG_FRIEND = 128;          // Members of the circle can invite their friends
	const CFG_LOCAL = 4096;              // Local even on GlobalScale
	const CFG_FEDERATED = 32768;         // Federated

In our example, we used 8+16+64=88 making the Circles OPEN, VISIBLE and JOINREQUEST, meaning that people can see the Circles in the listing, can join it but a request to join the Circles needs to be confirmed by a Moderator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants