Skip to content

Add support for creating permission invites (shares) to mail addressses - #3440

Draft
rhafer wants to merge 6 commits into
opencloud-eu:mainfrom
rhafer:invite-guest-mail
Draft

Add support for creating permission invites (shares) to mail addressses#3440
rhafer wants to merge 6 commits into
opencloud-eu:mainfrom
rhafer:invite-guest-mail

Conversation

@rhafer

@rhafer rhafer commented Sep 1, 2026

Copy link
Copy Markdown
Member

This is reviving #2717, rebased and adapted to the changes we did to the reva APIs since then.

There is still some stuff left to do:

  • introduce a config knob for the feature, disabled by default as this feature does not make much sense (apart from testing purposes e.g. for the UI) without the token creating and authentication features implemented
  • switch to using the email property of the DriveRecipient instead of using objectId and @libregraphibre.graph.recipient.type=mail. (As suggested in: Add support for mail grantees #2717 (review))
  • introduce a separate permission in the settings service that is used to check whether the user is authorized to create a mail invite (if we have the above config know, this can happen in a separate PR)
  • bump reva after Add support for mail grantees reva#785 got merged

The httpyac for the original PR is still supposed to work:

###
// @title initiate first upload
// @name upload1
{{
  $global.filename=new Buffer($random.alphabetic(50)+'.txt', 'utf-8').toString('base64')
  console.log("Generating new filename: " + $global.filename);
}}

### get personal drive
# @name personaldrive
GET {{host}}/graph/v1.0/me/drive?$select=id
Authorization: Basic {{username}}:{{password}}

### Upload file
PUT {{host}}/remote.php/dav/spaces/{{personaldrive.id}}/{{$global.filename}}
Authorization: Basic {{username}}:{{password}}
X-OC-Mtime: 1565233093
Content-Type: text/plain

uploaded content

?? status == 201

### Get file id
PROPFIND {{host}}/remote.php/dav/spaces/{{personaldrive.id}}/{{$global.filename}}
Authorization: Basic {{username}}:{{password}}
?? status == 207
{{

    const {select} = require("xpath");
    try{
        $global.fileid = select("//*[local-name(.)='id']/text()", response.parsedBody)[0].nodeValue;
    }catch(err){
        console.error(err);
    }
    console.log("id:", $global.fileid)    ;
}}

### Get viewer role
# @name roles
GET {{host}}/graph/v1beta1/roleManagement/permissions/roleDefinitions
Authorization: Basic {{username}}:{{password}}
?? status == 200


### Invite a single guest using an email address
POST {{host}}/graph/v1beta1/drives/{{personaldrive.id}}/items/{{$global.fileid}}/invite
Authorization: Basic {{username}}:{{password}}
Content-Type: application/json

{
    "recipients": [
        {
            "objectId": "some.guest@example.com",
            "@libre.graph.recipient.type": "mail"
        }
    ],
    "roles": ["{{roles[0].id}}"]
}


### List existing shares
# @name listshares
GET {{host}}/graph/v1beta1/drives/{{personaldrive.id}}/items/{{$global.fileid}}/permissions
Authorization: Basic {{username}}:{{password}}
?? status == 200
{{
    const shares = response.parsedBody.value;
    $global.shareId = shares[0].id;
}}

### Update permission role
PATCH {{host}}/graph/v1beta1/drives/{{personaldrive.id}}/items/{{$global.fileid}}/permissions/{{$global.shareId}}
Authorization: Basic {{username}}:{{password}}
Content-Type: application/json

{
    "roles": ["{{roles[0].id}}"]
}
?? status == 200

@codacy-production

codacy-production Bot commented Sep 1, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage 56.55% diff coverage · +0.05% coverage variation

Metric Results
Coverage variation +0.05% coverage variation (-1.00%)
Diff coverage 56.55% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (249d105) 87702 20433 23.30%
Head commit (0984c08) 87805 (+103) 20501 (+68) 23.35% (+0.05%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3440) 168 95 56.55%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

3 participants