Repository navigation
Conversation
Users never got a notification when a federated instance shared something with them or removed that share again. The ocmcore service publishes OCMCoreShareCreated and OCMCoreShareDelete, but only when it has an events config, and the ocm service never passed one. We now pass the events config to ocmcore, and userlog turns both events into the regular "Resource shared" / "Resource unshared" notifications for the grantee. They honor the same in-app settings as local shares. The sharer is a federated user, so we look it up with GetAcceptedUser in the name of the grantee. That call has to go out without the service account token, otherwise the invite manager filters by the service account and finds nothing. If the lookup fails, e.g. because the federated connection was deleted, the notification says "Someone at <provider domain> shared <resource> with you" instead of showing an empty name. The federated id itself is "<uuid>@<issuer url>", which tells the reader nothing. Clients only fill in the known rich parameters, so we fill in the provider in the rich message ourselves. The resource lives on the remote instance. The notification points to the received share id for both events and carries the resource name without an id, so clients render it like a local share but don't build a link to a resource that does not exist here. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 22 |
🟢 Coverage 70.89% diff coverage · +0.10% coverage variation
Metric Results Coverage variation ✅ +0.10% coverage variation (-1.00%) Diff coverage ✅ 70.89% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (90e03ba) 94306 28337 30.05% Head commit (3320159) 94383 (+77) 28458 (+121) 30.15% (+0.10%) 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 (#4071) 79 56 70.89% 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.
micbar
left a comment
There was a problem hiding this comment.
Nice feature! Two bugs, see the comments: the provider in messageRich and the sharer in the unshare event.
| return OC10Notification{}, err | ||
| } | ||
| // clients only know how to fill in the rich parameters, so we fill in the provider ourselves | ||
| msgraw = strings.ReplaceAll(msgraw, "{provider}", provider) |
There was a problem hiding this comment.
provider comes from the remote side and ends up unescaped in messageRich. The web client renders messageRich as HTML and only escapes the rich parameters, so a remote instance can put markup into the notification of a local user.
Please pass the provider as a rich parameter like user and resource, the clients escape those. Checking that it is a plain hostname before using it would not hurt either.
Thanks!
| // ocm share related | ||
| case events.OCMCoreShareCreated: | ||
| return c.ocmShareMessage(eventid, ShareCreated, ShareCreatedByProvider, ev.Sharer, ev.GranteeUserID, ev.ShareID, ev.ResourceName, utils.TSToTime(ev.CTime)) | ||
| case events.OCMCoreShareDelete: |
There was a problem hiding this comment.
The delete event has the owner of the share as Sharer, the create event has the creator (see ocmcore.go in reva). When someone shares a file from a project space, the unshare notification names the space owner or falls back to "Someone at ...", not the person who removed the share. The executant filter in consumer/service.go has the same problem.
I think reva needs to send the creator in the delete event.
| if err != nil { | ||
| return nil | ||
| } | ||
| res, err := gwc.GetAcceptedUser(context.Background(), &invitepb.GetAcceptedUserRequest{ |
There was a problem hiding this comment.
All errors are dropped here without a log line, a failed lookup is not cached and the call has no deadline. If the invite manager hangs, GET /notifications hangs with it.
Please log the error and use a context with a timeout.
| And user "Brian" should get a notification with subject "Resource shared" and message: | ||
| | message | | ||
| | Alice Hansen shared folderToShare with you | | ||
| But user "Brian" should not have a notification related to resource "folderToShare" with subject "Resource unshared" |
There was a problem hiding this comment.
This step also passes when the setting is ignored. The unshare reaches userlog asynchronously and the step checks only once, right after the 204. Can we wait for something that happens after the unshare, or retry until the timeout before we assert that nothing came?
| Message: l10n.Template("{user} unshared {resource} with you"), | ||
| } | ||
|
|
||
| // used for federated shares when the sharer cannot be resolved |
There was a problem hiding this comment.
Nit: godoc comments for the two new exported templates, e.g. // ShareCreatedByProvider is used for federated shares when the sharer cannot be resolved.
Users now get an in-app notification when a federated instance shares a resource with them or removes that share again. Before, the ocmcore service never published
OCMCoreShareCreated/OCMCoreShareDeletebecause the ocm service did not pass it an events config, and userlog did not know these events.ocmcoreThe sharer is a federated user, so we resolve it with
GetAcceptedUserin the name of the grantee. The call goes out without the service account token, otherwise the invite manager filters by the service account and finds nothing. If the lookup fails, e.g. because the federated connection was deleted, the message becomesinstead of an empty name. The federated id is
<uuid>@<issuer url>, which tells the reader nothing. Clients only fill in the known rich parameters, so the provider is filled intomessageRichon the server.The resource lives on the remote instance:
object_idandmessageRichParameters.share.idare the received share id for both events, andmessageRichParameters.resourceonly carries the name. With an id, web would build a private link to a resource that does not exist here.Port of
owncloud/ocis#11162, with the fallback, the consistent share id and the resource name as differences.The new
apiOcm/notification.featurecovers share, unshare and a disabled "Share Removed" setting across both instances. I ran it locally against two instances (3 scenarios, 39 steps passed), plus unit tests for the converter.AI assistance: Claude Code (claude-opus-5-5) ported the change, wrote the unit and acceptance tests and this description.