Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

fix: hide report option for the system user (#3549)

Jiralite8be2c38ff6ae
diff --git a/fluxer_api/src/api/report/ReportService.ts b/fluxer_api/src/api/report/ReportService.ts
index c6cf119ab..d5afaf736 100644
--- a/fluxer_api/src/api/report/ReportService.ts
+++ b/fluxer_api/src/api/report/ReportService.ts
@@ -25,6 +25,7 @@ import {
guildToContentWarningView,
} from '@app/api/channel/utils/EffectiveContentWarning';
import {resolveNsfwScopeChannel} from '@app/api/channel/utils/ThreadNsfwScope';
+import {isSyntheticUserId} from '@app/api/constants/Core';
import type {MessageAttachment} from '@app/api/database/types/MessageTypes';
import type {
DSAReportTicketRow,
@@ -408,7 +409,7 @@ export class ReportService {
throw new CannotReportYourselfError();
}
const reportedUser = await this.userRepository.findUnique(reportedUserId);
- if (!reportedUser) {
+ if (!reportedUser || isSyntheticUserId(reportedUserId)) {
throw new UnknownUserError();
}
const reportId = createReportID(await this.snowflakeService.generate());
diff --git a/fluxer_api/src/api/report/tests/ContentReporting.test.ts b/fluxer_api/src/api/report/tests/ContentReporting.test.ts
index cfb4c7999..e94d230a2 100644
--- a/fluxer_api/src/api/report/tests/ContentReporting.test.ts
+++ b/fluxer_api/src/api/report/tests/ContentReporting.test.ts
@@ -180,6 +180,13 @@ describe('Content Reporting', () => {
expect((await readReport(member.report_id)).reportedGuildId?.toString()).toBe(guild.id);
expect(await countReports()).toBe(2);
});
+ test('should reject a report against the system account', async () => {
+ const reporter = await createTestAccount(harness);
+ await reportUser(harness, reporter.token, '0')
+ .expect(HTTP_STATUS.NOT_FOUND, APIErrorCodes.UNKNOWN_USER)
+ .execute();
+ expect(await countReports()).toBe(0);
+ });
test('sends a localized system DM and email marker when a report is reviewed with a public comment', async () => {
const reporter = await createTestAccount(harness);
const targetUser = await createTestAccount(harness);
diff --git a/fluxer_app/src/features/user/components/modals/UserProfileActionsSheet.tsx b/fluxer_app/src/features/user/components/modals/UserProfileActionsSheet.tsx
index 37c5f69f4..3bfc73e5c 100644
--- a/fluxer_app/src/features/user/components/modals/UserProfileActionsSheet.tsx
+++ b/fluxer_app/src/features/user/components/modals/UserProfileActionsSheet.tsx
@@ -357,7 +357,7 @@ export const UserProfileActionsSheet: React.FC<UserProfileActionsSheetProps> = o
},
]
: []),
- ...(showReportUserProfile
+ ...(showReportUserProfile && !user.system
? [
{
icon: <FlagIcon className={styles.icon} data-flx="user.user-profile-actions-sheet.icon--12" />,
@@ -385,7 +385,9 @@ export const UserProfileActionsSheet: React.FC<UserProfileActionsSheetProps> = o
});
}
}
- menuGroups.push({items: reportBlockItems});
+ if (reportBlockItems.length > 0) {
+ menuGroups.push({items: reportBlockItems});
+ }
}
return (
<MenuBottomSheet
diff --git a/fluxer_app/src/features/user/components/modals/UserProfileModal.tsx b/fluxer_app/src/features/user/components/modals/UserProfileModal.tsx
index 52a1df1c5..3e97e201c 100644
--- a/fluxer_app/src/features/user/components/modals/UserProfileModal.tsx
+++ b/fluxer_app/src/features/user/components/modals/UserProfileModal.tsx
@@ -321,9 +321,6 @@ export const UserProfileModal: UserProfileModalComponent = observer(
}
};
const renderBlockMenuItem = (onClose: () => void) => {
- if (displayUser?.system) {
- return null;
- }
switch (relationshipType) {
case RelationshipTypes.BLOCKED:
return (
@@ -449,7 +446,7 @@ export const UserProfileModal: UserProfileModalComponent = observer(
</MenuItem>
</MenuGroup>
)}
- {!isCurrentUser && (
+ {!isCurrentUser && !displayUser.system && (
<MenuGroup data-flx="user.user-profile-modal.open-more-options-menu.menu-group--5">
<MenuItem
icon={<FlagIcon data-flx="user.user-profile-modal.open-more-options-menu.flag-icon" />}
diff --git a/fluxer_docs/src/content/docs/http-api/reports.mdx b/fluxer_docs/src/content/docs/http-api/reports.mdx
index 7168a4d19..3fcc22dd8 100644
--- a/fluxer_docs/src/content/docs/http-api/reports.mdx
+++ b/fluxer_docs/src/content/docs/http-api/reports.mdx
@@ -660,7 +660,7 @@ Files a report about another user's profile from the reporter's answers to the `
### Limitations
- A reporter naming their own account receives 400 `CANNOT_REPORT_YOURSELF`.
-- A `user_id` that resolves to no account returns 404 `UNKNOWN_USER`.
+- A `user_id` that resolves to no account, or to the system account, returns 404 `UNKNOWN_USER`.
- A `guild_id` that resolves to no guild, or to a guild the reporter is not a member of, returns 404 `UNKNOWN_GUILD`.
Fluxer checks the answers right after the claimed account and verified email checks, before the report ban check and before it looks up the user. An invalid walk still counts against the `report:create` bucket but not against the per-reporter allowance below.
@@ -689,7 +689,7 @@ Fluxer checks the answers right after the claimed account and verified email che
| 403 | [error response](/http-api/#error-response) | The credential is a bot token or OAuth2 bearer and the request returns `ACCESS_DENIED` |
| 403 | [error response](/http-api/#error-response) | Its email is unverified and the request returns `REPORT_EMAIL_VERIFICATION_REQUIRED` |
| 403 | [error response](/http-api/#error-response) | The account is report banned and the request returns `REPORT_BANNED` |
-| 404 | [error response](/http-api/#error-response) | The reported user does not exist and the request returns `UNKNOWN_USER` |
+| 404 | [error response](/http-api/#error-response) | The reported user does not exist or is the system account, and the request returns `UNKNOWN_USER` |
| 404 | [error response](/http-api/#error-response) | The supplied `guild_id` is not a guild the reporter is in and the request returns `UNKNOWN_GUILD` |
| 409 | [error response](/http-api/#error-response) | The answers came from an outdated flow and do not fit the current one, returning `REPORT_FLOW_OUTDATED` |
| 409<sup>1</sup> | [error response](/http-api/#error-response) | The reporter already reported this user within 24 hours, returning `CONFLICT` |