-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: rework resource store to return extra info #1350
feat: rework resource store to return extra info #1350
Conversation
Original comment: #1075 (comment) .
@RubenVerborgh Im not sure what you mean exactly. If, for example, there are multiple identifiers that were updated: Do we want to emit an |
The first. But the comment of @ixuz below there seems to indicate that there were problems with that idea so I don't think it's relevant anymore? |
Looking back at this and my previous comment, since then I've changed my mind and think the first option is reasonable. I recognize that some contextual information about the overall change may be lost(as each identifier is emitted individually), but on the other hand, we have not made use of that [extra contextual] information anyways in our other PR that leverages the feature of this PR. We can even see here that we're effectively breaking up the event into individual identifiers before passing to the next handler π Let's go with the first option. π |
Co-authored-by: Anton Wiklund <ixuz07@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Looks good to me! π
Now I think this PR is ready for merge, please have another look @joachimvh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No major changes requested, just some minor issues here and there. I did not read the comments/reviews above so if anything there was relevant to one of my comments do let me know.
One important note regarding the output type of the ResourceStore: in #1363 I introduce a Map that can safely use ResourceIdentifier
s as keys to make sure the same objects get reused and to be future-proof if we ever extend what such an object contains. This should also be used as the output type of the ResourceStore here instead of the Record<string, RepresentationMetadata>
currently used. So the interface would be a Map<ResourceIdentifier, RepresentationMetadata>
. That PR is not merged yet though so you currently can't do that so keep using the records until then. Depending on which PR gets merged first it can either be added here or I'll just to a small PR myself afterwards to do the change as the changes for this should be quite minimal
β¦hub.com:CommunitySolidServer/CommunitySolidServer into feat/rework-resource-store-to-return-extra-info
this.emit('changed', identifier); | ||
private emitChanged(changes: Record<string, RepresentationMetadata>): Record<string, RepresentationMetadata> { | ||
for (const [ key, value ] of Object.entries(changes)) { | ||
const activity = value.get(SOLID_AS.terms.Activity)?.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized this is going to error if there are multiple values for Activity. It can also potentially send invalid values in case the source store set a wrong value there. There should probably be checks for these cases to make sure this store only emits correct values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might have missed this comment since I made it after the review. But thinking on this again we should take into account other people making faulty stores so this can be ignored.
@joachimvh The CI seems bugged for me. It doesn't run and/or doesn't report. Could you take a look at that? |
It's because there is a merge conflict. The structure of the documentation folder changed recently so this will have to be modified in this PR. |
β¦-resource-store-to-return-extra-info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor refactor comments but then this should be ready to merge
this.emit('changed', identifier); | ||
private emitChanged(changes: Record<string, RepresentationMetadata>): Record<string, RepresentationMetadata> { | ||
for (const [ key, value ] of Object.entries(changes)) { | ||
const activity = value.get(SOLID_AS.terms.Activity)?.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might have missed this comment since I made it after the review. But thinking on this again we should take into account other people making faulty stores so this can be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I assume the plan is to now look at the notifications spec?
@BelgianNoise apparently there is still a conflict, can you look into what it is? Edit: you can ignore this, I was looking at the wrong setting. |
Indeed that's the next step in our plan π |
π Related issues
This PR is mostly based on work of @ixuz from #1075 .
Seemed like a good idea to branch of the current code as the linked PR is still based on v2.0.0 .
βοΈ Description
(Copy from other PR)
Preparation for implementation of Solid Notifications according to https://solid.github.io/notifications/protocol
The proposal refers to https://www.w3.org/TR/activitystreams-core/ for the activity types.
In order to provide meaningful notifications to subscribers we have differentiated between the types of resource changes, such as CREATED, CHANGED and DELETED.
This PR is backwards compatible as it only changes internal behavior.
β PR check list
Before this pull request can be merged, a core maintainer will check whether