-
Notifications
You must be signed in to change notification settings - Fork 13.8k
feat: status visibility #41747
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
Merged
+960
−51
Merged
feat: status visibility #41747
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
19783e1
feat: presence visibility
ricardogarim cf4b20d
chore: lint fix
ricardogarim dc609fd
refactor: swap status visibility mirror after its query resolves
ricardogarim c4a2c62
refactor: keep custom status at the top of the user menu
ricardogarim a6374fc
chore: log status visibility invalidation failures
ricardogarim 31c20df
chore: format status visibility presence call
ricardogarim 6049980
fix: hydrate status visibility mirror on startup
ricardogarim 27987d7
chore: index users with status visibility restrictions
ricardogarim 8c548df
chore: drop the status visibility design proposal
ricardogarim f0ba7ac
fix: close status visibility leaks in user listing endpoints
ricardogarim c9d0018
fix: emit status visibility block list as usernames to the client
ricardogarim 03ca065
fix: skip status visibility username lookup while the feature is off
ricardogarim 61219f5
fix: leak hidden status through the DM members status filter
ricardogarim 8c951b6
fix: return the status visibility block list as usernames to its owne…
ricardogarim a1cc699
fix: persist the status visibility block list as user ids
ricardogarim 28412e7
fix: omit the status visibility block list while the feature is off
ricardogarim bd232e6
fix: leak hidden status through the presence endpoint result set
ricardogarim 51bd8c4
fix: omit the status visibility block list while the feature is off
ricardogarim 1f8f281
Update .changeset/odd-steaks-pull.md
tassoevan 6c72054
refactor: split hook from component module
tassoevan e3e32eb
fix: pin mongodb type resolution in the ddp-streamer build
tassoevan abee57f
refactor: read the status visibility setting directly
ricardogarim 58ac632
refactor: destructure the redacted status fields
ricardogarim 36e09c4
refactor: move the presence status code map to core-typings
ricardogarim fb9b857
fix: read the status visibility setting through the settings service
ricardogarim d27f5a0
refactor: own status visibility state in a service
ricardogarim 0a6077b
chore: drop nullable from the status visibility preference
ricardogarim f4ff5aa
fix: type the status visibility query by what it projects
ricardogarim 075501c
refactor: extract the hidden users helpers
ricardogarim 06d8f71
fix: serialize status visibility refreshes
ricardogarim 03d03c6
fix: keep presence events in order by not awaiting in the listener
ricardogarim 8085328
fix: release the presence client when the subscription drops mid-refresh
ricardogarim 147f421
fix: only broadcast status visibility invalidation when something cha…
ricardogarim 0578ab7
fix: keep emitting presence when the visibility lookup fails
ricardogarim b769aa1
fix: check the current subscription when it drops mid-refresh
ricardogarim 695a36b
fix: release the presence client when the visibility lookup fails
ricardogarim d2cadc1
fix: stop relaying hidden users activity through the presence stream
ricardogarim bab167e
chore: drop the status visibility comments
ricardogarim aec34b2
refactor: derive presence clients from the streamer subscriptions
ricardogarim 7252424
fix: log status visibility invalidation failures
ricardogarim fc16e49
chore: restore the presence troubleshoot startup file name
ricardogarim 5cc65f9
refactor: extract the status visibility gate out of the presence service
ricardogarim 50efd33
fix: publish the presence stream through the base streamer
ricardogarim 4b4029a
fix: restore the presence stream publish path
ricardogarim a03bdff
perf: cache the status visibility setting per process
ricardogarim 2e33acf
chore: adjust setting to use unlimited-presence module
ricardogarim 73895ed
chore: filter own user from autocomplete
ricardogarim dfdf6e0
refactor: keep status visibility out of the presence service
ricardogarim ff5f305
chore: lint fix
ricardogarim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| '@rocket.chat/core-services': minor | ||
| '@rocket.chat/core-typings': minor | ||
| '@rocket.chat/i18n': minor | ||
| '@rocket.chat/meteor': minor | ||
| '@rocket.chat/model-typings': minor | ||
| '@rocket.chat/models': minor | ||
| '@rocket.chat/rest-typings': minor | ||
| --- | ||
|
|
||
| Adds status visibility, letting users hide their presence and status message from specific people they choose. Blocked people see that user as offline, indistinguishable from genuinely offline, and the block can be lifted at any time — changes apply live, without a reload. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusVisibilityModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { Box } from '@rocket.chat/fuselage'; | ||
| import { Field, FieldGroup, FieldHint, FieldLabel, FieldRow } from '@rocket.chat/fuselage-forms'; | ||
| import { GenericModal } from '@rocket.chat/ui-client'; | ||
| import { useEndpoint, useToastMessageDispatch, useUser } from '@rocket.chat/ui-contexts'; | ||
| import type { ComponentProps } from 'react'; | ||
| import { Controller, useForm } from 'react-hook-form'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| import UserAutoCompleteMultiple from '../../../components/UserAutoCompleteMultiple'; | ||
|
|
||
| export type EditStatusVisibilityModalProps = { | ||
| onClose: () => void; | ||
| }; | ||
|
|
||
| type StatusVisibilityFormValues = { | ||
| statusVisibilityDenied: string[]; | ||
| }; | ||
|
|
||
| export const EditStatusVisibilityModal = ({ onClose }: EditStatusVisibilityModalProps) => { | ||
| const { t } = useTranslation(); | ||
| const user = useUser(); | ||
| const dispatchToastMessage = useToastMessageDispatch(); | ||
| const setPreferences = useEndpoint('POST', '/v1/users.setPreferences'); | ||
|
|
||
| const { | ||
| control, | ||
| handleSubmit, | ||
| formState: { isDirty, isSubmitting }, | ||
| } = useForm<StatusVisibilityFormValues>({ | ||
| defaultValues: { | ||
| statusVisibilityDenied: user?.settings?.preferences?.statusVisibilityDenied ?? [], | ||
| }, | ||
| }); | ||
|
|
||
| const handleSave = async ({ statusVisibilityDenied }: StatusVisibilityFormValues) => { | ||
| try { | ||
| await setPreferences({ data: { statusVisibilityDenied } }); | ||
| dispatchToastMessage({ type: 'success', message: t('Accounts_StatusVisibility_Saved') }); | ||
| onClose(); | ||
| } catch (error) { | ||
| dispatchToastMessage({ type: 'error', message: error }); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <GenericModal | ||
| icon={null} | ||
| variant='warning' | ||
| title={t('Accounts_StatusVisibility_HideStatus')} | ||
| onCancel={onClose} | ||
| confirmText={t('Save')} | ||
| confirmDisabled={!isDirty || isSubmitting} | ||
| wrapperFunction={(props: ComponentProps<typeof Box>) => <Box is='form' onSubmit={handleSubmit(handleSave)} {...props} />} | ||
| > | ||
| <FieldGroup> | ||
| <Field> | ||
| <FieldLabel>{t('Accounts_StatusVisibility_HideFromUsers')}</FieldLabel> | ||
| <FieldRow> | ||
| <Controller | ||
| control={control} | ||
| name='statusVisibilityDenied' | ||
| render={({ field: { onChange, value } }) => ( | ||
| <UserAutoCompleteMultiple | ||
| value={value} | ||
| onChange={onChange} | ||
| exceptions={user?.username ? [user.username] : undefined} | ||
| placeholder={t('Select_users')} | ||
| /> | ||
| )} | ||
| /> | ||
| </FieldRow> | ||
| <FieldHint>{t('Accounts_StatusVisibility_HideFromUsers_Description')}</FieldHint> | ||
| </Field> | ||
| </FieldGroup> | ||
| </GenericModal> | ||
| ); | ||
| }; | ||
|
|
||
| export default EditStatusVisibilityModal; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...or/client/navbar/NavBarSettingsToolbar/UserMenu/hooks/useStatusVisibilityModalHandler.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { useSetModal } from '@rocket.chat/ui-contexts'; | ||
|
|
||
| import { EditStatusVisibilityModal } from '../EditStatusVisibilityModal'; | ||
|
|
||
| export const useStatusVisibilityModalHandler = () => { | ||
| const setModal = useSetModal(); | ||
|
|
||
| return () => setModal(<EditStatusVisibilityModal onClose={() => setModal(null)} />); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { expect } from 'chai'; | ||
|
|
||
| import { queryFiltersStatus } from './queryFiltersStatus'; | ||
|
|
||
| describe('queryFiltersStatus', () => { | ||
| it('should return false for a query without status fields', () => { | ||
| expect(queryFiltersStatus({ username: { $regex: 'ana' } })).to.be.equal(false); | ||
| }); | ||
|
|
||
| it('should return true for a top level status filter', () => { | ||
| expect(queryFiltersStatus({ status: 'online' })).to.be.equal(true); | ||
| }); | ||
|
|
||
| it('should return true for a status filter nested in $or', () => { | ||
| expect(queryFiltersStatus({ $or: [{ username: { $regex: '' } }, { status: 'online' }] })).to.be.equal(true); | ||
| }); | ||
|
|
||
| it('should return true for a status filter nested in $and inside $or', () => { | ||
| expect(queryFiltersStatus({ $or: [{ $and: [{ statusText: { $regex: 'lunch' } }] }] })).to.be.equal(true); | ||
| }); | ||
|
|
||
| it('should return true for any redacted status field', () => { | ||
| for (const field of ['statusText', 'statusSource', 'statusExpiresAt', 'statusDefault', 'statusConnection']) { | ||
| expect(queryFiltersStatus({ [field]: { $exists: true } })).to.be.equal(true); | ||
| } | ||
| }); | ||
|
|
||
| it('should return false for null and primitive values', () => { | ||
| expect(queryFiltersStatus(null)).to.be.equal(false); | ||
| expect(queryFiltersStatus('status')).to.be.equal(false); | ||
| expect(queryFiltersStatus(undefined)).to.be.equal(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export function queryFiltersStatus(query: unknown): boolean { | ||
| if (Array.isArray(query)) { | ||
| return query.some(queryFiltersStatus); | ||
| } | ||
|
|
||
| if (query === null || typeof query !== 'object') { | ||
| return false; | ||
| } | ||
|
|
||
| return Object.entries(query).some(([key, value]) => key.startsWith('status') || queryFiltersStatus(value)); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.