mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
fix(api): correct report targets and ticket handling (#2504)
This commit is contained in:
1 parent
1f627c9cc5
commit
632f4c7b6c
4 files changed
+219
-11
No files matched your search
@@ -61,7 +61,7 @@ export class SearchService {
|
||||
const {channel_id, channel_ids, context_channel_id, context_guild_id, ...searchParams} = data;
|
||||
const contextChannelId = context_channel_id ? createChannelID(context_channel_id) : null;
|
||||
const contextGuildId = context_guild_id ? createGuildID(context_guild_id) : null;
|
||||
const channelIds = channel_ids?.map((id) => createChannelID(id)) ?? [];
|
||||
const channelIds = (channel_ids ?? channel_id)?.map((id) => createChannelID(id)) ?? [];
|
||||
const scope = searchParams.scope ?? 'current';
|
||||
let result: MessageSearchResponse;
|
||||
switch (scope) {
|
||||
|
||||
@@ -12,7 +12,12 @@ import {
|
||||
createGuild,
|
||||
getChannel,
|
||||
} from '../../guild/tests/GuildTestUtils';
|
||||
import {markChannelAsIndexed, pinMessage, sendMessage} from '../../message/tests/MessageTestUtils';
|
||||
import {
|
||||
markChannelAsIndexed,
|
||||
markGuildChannelsAsIndexed,
|
||||
pinMessage,
|
||||
sendMessage,
|
||||
} from '../../message/tests/MessageTestUtils';
|
||||
import {type ApiTestHarness, createApiTestHarness} from '../../test/ApiTestHarness';
|
||||
import {HTTP_STATUS} from '../../test/TestConstants';
|
||||
import {createBuilder} from '../../test/TestRequestBuilder';
|
||||
@@ -292,6 +297,55 @@ describe('Message Search Filters', () => {
|
||||
expect(result.messages.every((m) => m.channel_id !== channel3.id)).toBe(true);
|
||||
}
|
||||
});
|
||||
test('channel_id narrows scope like channel_ids', async () => {
|
||||
const account = await createTestAccount(harness);
|
||||
const guild = await createGuild(harness, account.token, 'Channel Id Alias Guild');
|
||||
const channel1 = await getChannel(harness, account.token, guild.system_channel_id!);
|
||||
const channel2 = await createChannel(harness, account.token, guild.id, 'alias-second-channel');
|
||||
const timestamp = Date.now();
|
||||
const baseContent = `channel-id-alias-${timestamp}`;
|
||||
await sendMessage(harness, account.token, channel1.id, `${baseContent} channel1 msg`);
|
||||
await sendMessage(harness, account.token, channel2.id, `${baseContent} channel2 msg`);
|
||||
await markGuildChannelsAsIndexed(harness, account.token, guild.id);
|
||||
const result = await createBuilder<MessageSearchResponse>(harness, account.token)
|
||||
.post('/search/messages')
|
||||
.body({
|
||||
content: baseContent,
|
||||
scope: 'all_guilds',
|
||||
channel_id: [channel1.id],
|
||||
})
|
||||
.expect(HTTP_STATUS.OK)
|
||||
.execute();
|
||||
if (!isSearchResult(result)) {
|
||||
expect.fail('Expected search result but got indexing response');
|
||||
}
|
||||
expect(result.messages.length).toBeGreaterThan(0);
|
||||
for (const msg of result.messages) {
|
||||
expect(msg.channel_id).toBe(channel1.id);
|
||||
}
|
||||
expect(result.messages.every((m) => m.channel_id !== channel2.id)).toBe(true);
|
||||
});
|
||||
test('channel_id outside the resolved scope returns 403', async () => {
|
||||
const account = await createTestAccount(harness);
|
||||
const outsider = await createTestAccount(harness);
|
||||
const guild = await createGuild(harness, account.token, 'Channel Id Scope Guild');
|
||||
const outsideGuild = await createGuild(harness, outsider.token, 'Channel Id Outside Guild');
|
||||
const timestamp = Date.now();
|
||||
const baseContent = `channel-id-scope-${timestamp}`;
|
||||
await sendMessage(harness, account.token, guild.system_channel_id!, `${baseContent} own msg`);
|
||||
await sendMessage(harness, outsider.token, outsideGuild.system_channel_id!, `${baseContent} outside msg`);
|
||||
await markGuildChannelsAsIndexed(harness, account.token, guild.id);
|
||||
await markGuildChannelsAsIndexed(harness, outsider.token, outsideGuild.id);
|
||||
await createBuilder<MessageSearchResponse>(harness, account.token)
|
||||
.post('/search/messages')
|
||||
.body({
|
||||
content: baseContent,
|
||||
scope: 'all_guilds',
|
||||
channel_id: [outsideGuild.system_channel_id!],
|
||||
})
|
||||
.expect(HTTP_STATUS.FORBIDDEN, 'MISSING_PERMISSIONS')
|
||||
.execute();
|
||||
});
|
||||
});
|
||||
describe('Content Type Filtering (has/exclude_has)', () => {
|
||||
test('has: link finds messages with links', async () => {
|
||||
|
||||
Reference in new issue
Block a user