Skip to content

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

TypeScript fluxerfluxerapp

fix(api): personal notes default to on unless DMs disabled (#3650)

Hampus71c0daf0e792
diff --git a/fluxer_api/src/api/channel/tests/PersonalNotesInstancePolicy.test.ts b/fluxer_api/src/api/channel/tests/PersonalNotesInstancePolicy.test.ts
index 27478403f..2ce252a76 100644
--- a/fluxer_api/src/api/channel/tests/PersonalNotesInstancePolicy.test.ts
+++ b/fluxer_api/src/api/channel/tests/PersonalNotesInstancePolicy.test.ts
@@ -2,11 +2,8 @@
import type {TestAccount} from '@app/api/auth/tests/AuthTestUtils';
import {createTestAccount, setUserACLs} from '@app/api/auth/tests/AuthTestUtils';
-import {createUserID, userIdToChannelId} from '@app/api/BrandedTypes';
import {Config} from '@app/api/Config';
import {sendChannelMessage} from '@app/api/channel/tests/ChannelTestUtils';
-import {ensureSessionStarted} from '@app/api/message/tests/MessageTestUtils';
-import {getChannelRepository} from '@app/api/middleware/ServiceSingletons';
import type {ApiTestHarness} from '@app/api/test/ApiTestHarness';
import {createApiTestHarness} from '@app/api/test/ApiTestHarness';
import {HTTP_STATUS} from '@app/api/test/TestConstants';
@@ -71,22 +68,11 @@ describe('personal notes instance policy', () => {
await sendChannelMessage(harness, alice.token, alice.userId, 'a note to self');
});
- it('is off by default on a self-hosted instance and does not create the channel', async () => {
+ it('is on by default on a self-hosted instance with direct messages enabled', async () => {
Config.instance.selfHosted = true;
const alice = await createTestAccount(harness);
- await ensureSessionStarted(harness, alice.token);
- const config = await createBuilder<InstanceConfigResponse>(harness, admin.token)
- .get('/admin/instance/config')
- .execute();
- expect(config.policy.personal_notes_enabled).toBe(false);
- expect(await discoveredPersonalNotesEnabled()).toBe(false);
- await startSession(alice);
- expect(
- await getChannelRepository().channelData.findUnique(userIdToChannelId(createUserID(BigInt(alice.userId)))),
- ).toBeNull();
- await expectRefused(
- createBuilder(harness, alice.token).post(`/channels/${alice.userId}/messages`).body({content: 'hello'}),
- );
+ expect(await discoveredPersonalNotesEnabled()).toBe(true);
+ await sendChannelMessage(harness, alice.token, alice.userId, 'a note to self');
});
it('refuses personal notes while off and brings existing notes back when turned on', async () => {
diff --git a/fluxer_api/src/api/instance/InstanceConfigRepository.ts b/fluxer_api/src/api/instance/InstanceConfigRepository.ts
index e7b5f71db..f9a26c970 100644
--- a/fluxer_api/src/api/instance/InstanceConfigRepository.ts
+++ b/fluxer_api/src/api/instance/InstanceConfigRepository.ts
@@ -1047,7 +1047,7 @@ const StoredInstancePolicySchema = z
.transform(({friends_disabled, personal_notes_enabled, ...policy}) => ({
...policy,
friends_disabled: friends_disabled ?? policy.direct_messages_disabled,
- personal_notes_enabled: personal_notes_enabled ?? !Config.instance.selfHosted,
+ personal_notes_enabled: personal_notes_enabled ?? !policy.direct_messages_disabled,
})) satisfies z.ZodType<InstancePolicyConfig>;
const StoredInstanceNoticeSchema = InstanceNoticeSchema.nullable().default(null);