From 194d656bb47bb2fd5c213ea0d8b731b26cad726c Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 17 Feb 2023 09:06:31 +0100 Subject: [PATCH 001/118] fix: normalize empty value of `name` into an absent value --- .../backend/src/core/activitypub/models/ApPersonService.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts index a1fdd7a19..d06958da0 100644 --- a/packages/backend/src/core/activitypub/models/ApPersonService.ts +++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts @@ -164,6 +164,9 @@ export class ApPersonService implements OnModuleInit { throw new Error('invalid Actor: wrong name'); } x.name = truncate(x.name, nameLength); + } else if (x.name === '') { + // Mastodon emits empty string when the name is not set. + x.name = undefined; } if (x.summary) { if (!(typeof x.summary === 'string' && x.summary.length > 0)) { From 8c64f999dca32a781adfa4ddec2bf8fa63dc1abd Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sun, 19 Feb 2023 09:49:18 +0100 Subject: [PATCH 002/118] Add test --- packages/backend/test/unit/activitypub.ts | 68 +++++++++++++---------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/packages/backend/test/unit/activitypub.ts b/packages/backend/test/unit/activitypub.ts index 3d0032507..5335dff6d 100644 --- a/packages/backend/test/unit/activitypub.ts +++ b/packages/backend/test/unit/activitypub.ts @@ -11,8 +11,25 @@ import { GlobalModule } from '@/GlobalModule.js'; import { CoreModule } from '@/core/CoreModule.js'; import { FederatedInstanceService } from '@/core/FederatedInstanceService.js'; import { LoggerService } from '@/core/LoggerService.js'; +import type { IActor } from '@/core/activitypub/type.js'; import { MockResolver } from '../misc/mock-resolver.js'; +const host = 'https://host1.test'; + +function createRandomActor(): IActor & { id: string } { + const preferredUsername = `${rndstr('A-Z', 4)}${rndstr('a-z', 4)}`; + const actorId = `${host}/users/${preferredUsername.toLowerCase()}`; + + return { + '@context': 'https://www.w3.org/ns/activitystreams', + id: actorId, + type: 'Person', + preferredUsername, + inbox: `${actorId}/inbox`, + outbox: `${actorId}/outbox`, + }; +} + describe('ActivityPub', () => { let noteService: ApNoteService; let personService: ApPersonService; @@ -36,18 +53,7 @@ describe('ActivityPub', () => { }); describe('Parse minimum object', () => { - const host = 'https://host1.test'; - const preferredUsername = `${rndstr('A-Z', 4)}${rndstr('a-z', 4)}`; - const actorId = `${host}/users/${preferredUsername.toLowerCase()}`; - - const actor = { - '@context': 'https://www.w3.org/ns/activitystreams', - id: actorId, - type: 'Person', - preferredUsername, - inbox: `${actorId}/inbox`, - outbox: `${actorId}/outbox`, - }; + const actor = createRandomActor(); const post = { '@context': 'https://www.w3.org/ns/activitystreams', @@ -80,29 +86,31 @@ describe('ActivityPub', () => { }); }); - describe('Truncate long name', () => { - const host = 'https://host1.test'; - const preferredUsername = `${rndstr('A-Z', 4)}${rndstr('a-z', 4)}`; - const actorId = `${host}/users/${preferredUsername.toLowerCase()}`; + describe('Name field', () => { + test('Truncate long name', async () => { + const actor = { + ...createRandomActor(), + name: rndstr('0-9a-z', 129), + }; - const name = rndstr('0-9a-z', 129); - - const actor = { - '@context': 'https://www.w3.org/ns/activitystreams', - id: actorId, - type: 'Person', - preferredUsername, - name, - inbox: `${actorId}/inbox`, - outbox: `${actorId}/outbox`, - }; - - test('Actor', async () => { resolver._register(actor.id, actor); const user = await personService.createPerson(actor.id, resolver); - assert.deepStrictEqual(user.name, actor.name.substr(0, 128)); + assert.deepStrictEqual(user.name, actor.name.slice(0, 128)); + }); + + test('Normalize empty name', async () => { + const actor = { + ...createRandomActor(), + name: '', + }; + + resolver._register(actor.id, actor); + + const user = await personService.createPerson(actor.id, resolver); + + assert.strictEqual(user.name, null); }); }); }); From d90a98a8a78d2a66aae347eaa0ec57ee11967535 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 6 Mar 2023 22:02:51 +0100 Subject: [PATCH 003/118] =?UTF-8?q?fix(frontend/MkMediaList):=20alt?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AEnewline?= =?UTF-8?q?=E3=82=92=E8=AA=8D=E8=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkMediaList.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkMediaList.vue b/packages/frontend/src/components/MkMediaList.vue index c768a086c..d36cc2d26 100644 --- a/packages/frontend/src/components/MkMediaList.vue +++ b/packages/frontend/src/components/MkMediaList.vue @@ -118,7 +118,7 @@ onMounted(() => { }); lightbox.init(); - + window.addEventListener('popstate', () => { if (lightbox.pswp && lightbox.pswp.isOpen === true) { lightbox.pswp.close(); @@ -239,5 +239,6 @@ const previewable = (file: misskey.entities.DriveFile): boolean => { max-height: 8em; overflow-y: auto; text-shadow: var(--bg) 0 0 10px, var(--bg) 0 0 3px, var(--bg) 0 0 3px; + white-space: pre-line; } From 2b884ba3388ee7104f71ce175df9a5c629e73553 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 7 Mar 2023 08:41:10 +0900 Subject: [PATCH 004/118] enhance(server): tweak notes/featured api --- packages/backend/src/server/api/endpoints/notes/featured.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/notes/featured.ts b/packages/backend/src/server/api/endpoints/notes/featured.ts index cf939f663..6bf17b222 100644 --- a/packages/backend/src/server/api/endpoints/notes/featured.ts +++ b/packages/backend/src/server/api/endpoints/notes/featured.ts @@ -71,7 +71,7 @@ export default class extends Endpoint { let notes = await query .orderBy('note.score', 'DESC') - .take(50) + .take(100) .getMany(); notes.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()); From 3ecb8633729bf743658fa22d5b0bea49cffa22a0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 7 Mar 2023 09:37:02 +0900 Subject: [PATCH 005/118] enhance(client): improve mute-block page --- .../src/pages/settings/mute-block.vue | 145 ++++++++++++++++-- 1 file changed, 133 insertions(+), 12 deletions(-) diff --git a/packages/frontend/src/pages/settings/mute-block.vue b/packages/frontend/src/pages/settings/mute-block.vue index a08308f0c..577337868 100644 --- a/packages/frontend/src/pages/settings/mute-block.vue +++ b/packages/frontend/src/pages/settings/mute-block.vue @@ -5,22 +5,60 @@
- - -