-
Notifications
You must be signed in to change notification settings - Fork 434
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
fix(capabilities): implement a wrapper for capabilities #12208
Conversation
e1c3b1f
to
47bb67c
Compare
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 can use store instead of browser storage. The purpose of keeping the last previous fetched capabilities is to check in case the new fetch renders a different list (on the same page) -> store is enough for that.
This comment was marked as resolved.
This comment was marked as resolved.
47bb67c
to
0bf4beb
Compare
0bf4beb
to
77bc7dd
Compare
77bc7dd
to
326799e
Compare
326799e
to
30650ac
Compare
src/services/CapabilitiesManager.ts
Outdated
public hasTalkFeature(token: 'local'|string, feature: string): boolean { | ||
if (this.localCapabilities.spreed['features-local'].includes(feature)) { | ||
return this.localCapabilities?.spreed?.features?.includes(feature) ?? false | ||
} | ||
return this.getCapabilities(token)?.spreed?.features?.includes(feature) ?? false | ||
} |
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.
If the feature is local, we don't need to check remote server at all because those features are usually not affecting the chat, call etc (e.g: note-to-self)
If the feature is not flagged as local, both remote and local capabilities should be checked using AND
(if any of the server doesn't have that feature, it should not be there).
Note: we need to be careful when flagging feature/config with local, I noticed that config => attachments => allowed
is local whereas it is affecting the chat.
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.
I'd agree that feature should be respected from both local / remote, if that's related to the conversation; remote user shouldn't have more possibilities, than he already has locally, and more than a local user:
Remote cap. | Local cap. | Resulting | Example |
---|---|---|---|
🔴 | 🔴 | 🔴 | Not conflicting |
🟢 | 🟢 | 🟢 | Not conflicting |
🟢 | 🔴 | 🔴 | "Moderator" from 29 can't ban participants, because he isn't aware of the feature |
🔴 | 🟢 | 🔴 | Can't upload attachments, if not allowed on remote server |
But for the config, i think remote should be respected, unless we define it in config-local
: as we have numeric and string values there, not only boolean
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.
But for the config, i think remote should be respected, unless we define it in config-local: as we have numeric and string values there, not only boolean
For config, it's a bit tricky, maybe min(remote, local) for numeric config and for not measurable numeric (like integers to reflect modes), use remote, right ?
For now, chat-read-status
(local) which should be following remote server, no ?
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.
Or we treat each config individually for now.
chat-read-status differs per user and set up by him, if I'm not mistaken, so should be from local
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.
chat-read-status
(local) - On conversation API v3 and the chat API the last common read message is exposed which can be used to update the "read status" flag of own chat messages. The info should be shown only when the user also shares their read status. The user's value can be found inconfig => chat => read-privacy
.
That means it is first configured by server (expose the last common read message) and then enabled/disabled by user.
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.
chat-read-status
isn't used in frontend code, so consider this out of scope of this PR. Let's stick with:
- features should be respected on both
- configs should be respected from remote, unless we don't define them as local || unless we don't set code to respect both individually for each case
Speaking of which, @nickvergessen :
config => attachments => allowed
, shouldn't we respect both local and remote?
features => avatar
, aren't we proxying the same local endpoint for avatar, so only local is enough?
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.
yeah the docs might be from before we decided to proxy avatars.
As for attachments, I guess we should check both, but we can clarify once we implement them
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.
Looks very cool!
Just some implementation nitpicks and questions.
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.
Looks good to me ✨
- check talk-hash when joining federated conversation - keep and retrieve capabilities from BrowserStorage - distinguish cases for local and remote capabilities - implement 'hasTalkFeature' and 'getTalkConfig' helpers - respect local-only features and configs Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
…with conversation switch) Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
…ion related) Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
36dff6f
to
e3bdf72
Compare
Rebased onto main and resolved conflicts (message components and composables) |
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.
Tested 🦅
☑️ Resolves
🖌️ UI Checklist
🖼️ Screenshots / Screencasts
No visual changes
🚧 Tasks
As it's a request to server, it should be asyncronous. That means we must in some case to wait for remote capabilities or re-render application based on response (which is now isn't happen and requires a reload, if capability has changed
Reload as we do for dirty hash
hasFeature
to replace longgetCapabilities()?.spreed?.features?.includes('capability')
🏁 Checklist