From 6ed13ea9a70648e4bd7d65cd40eeafde4a309b07 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 10:23:03 +0100 Subject: [PATCH 1/8] fix typo, the 2nd --- packages/client/src/components/global/url.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/components/global/url.vue b/packages/client/src/components/global/url.vue index 47811ae00..5b4e831b1 100644 --- a/packages/client/src/components/global/url.vue +++ b/packages/client/src/components/global/url.vue @@ -35,7 +35,7 @@ const props = withDefaults(defineProps<{ const self = props.url.startsWith(local); const uri = new URL(props.url); -if (!['http:', 'https:'].includes(url.protocol)) throw new Error('invalid url'); +if (!['http:', 'https:'].includes(uri.protocol)) throw new Error('invalid url'); let el: HTMLElement | null = $ref(null); let schema = $ref(uri.protocol); From 7c89e99243191e3fe41fe139cc3ce34c5847361c Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 12:52:28 +0100 Subject: [PATCH 2/8] fix registry migration It can happen that registry items were created at exactly the same time for some reason. --- .../backend/migration/1675375940759-registry-remove-domain.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/migration/1675375940759-registry-remove-domain.js b/packages/backend/migration/1675375940759-registry-remove-domain.js index d3ee12ca9..41ca930f3 100644 --- a/packages/backend/migration/1675375940759-registry-remove-domain.js +++ b/packages/backend/migration/1675375940759-registry-remove-domain.js @@ -5,8 +5,8 @@ export class registryRemoveDomain1675375940759 { await queryRunner.query(`DROP INDEX "public"."IDX_0a72bdfcdb97c0eca11fe7ecad"`); await queryRunner.query(`ALTER TABLE "registry_item" DROP COLUMN "domain"`); await queryRunner.query(`ALTER TABLE "registry_item" ALTER COLUMN "key" TYPE text USING "key"::text`); - // delete existing duplicated entries, keeping the latest updated one - await queryRunner.query(`DELETE FROM "registry_item" AS "a" WHERE "updatedAt" != (SELECT MAX("updatedAt") FROM "registry_item" AS "b" WHERE "a"."userId" = "b"."userId" AND "a"."key" = "b"."key" AND "a"."scope" = "b"."scope" GROUP BY "userId", "key", "scope")`); + // delete existing duplicated entries, keeping the latest created one + await queryRunner.query(`DELETE FROM "registry_item" AS "a" WHERE "id" != (SELECT MAX("id") FROM "registry_item" AS "b" WHERE "a"."userId" = "b"."userId" AND "a"."key" = "b"."key" AND "a"."scope" = "b"."scope" GROUP BY "userId", "key", "scope")`); await queryRunner.query(`ALTER TABLE "registry_item" ADD CONSTRAINT "UQ_b8d6509f847331273ab99daccc7" UNIQUE ("userId", "key", "scope")`); } From fff93c696565b9ee46a5ab653766cf1793f94f4f Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 17:25:24 +0100 Subject: [PATCH 3/8] activitypub: remove _misskey_content attribute As already noted back in https://github.com/misskey-dev/misskey/pull/8787 the intention was to replace the `_misskey_content` attribute with the ActivityPub-defined `source` property. Misskey and by extension Foundkey have shipped with the `source` property and the respective parsing for quite a while so it seems reasonable to remove it now. Changelog: Removed --- packages/backend/src/remote/activitypub/models/note.ts | 2 -- packages/backend/src/remote/activitypub/renderer/index.ts | 1 - packages/backend/src/remote/activitypub/renderer/note.ts | 1 - 3 files changed, 4 deletions(-) diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index fb9621b85..d7adc7b67 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -207,8 +207,6 @@ export async function createNote(value: string | IObject, resolver: Resolver, si let text: string | null = null; if (note.source?.mediaType === 'text/x.misskeymarkdown' && typeof note.source.content === 'string') { text = note.source.content; - } else if (typeof note._misskey_content !== 'undefined') { - text = note._misskey_content; } else if (typeof note.content === 'string') { text = fromHtml(note.content, quote?.uri); } diff --git a/packages/backend/src/remote/activitypub/renderer/index.ts b/packages/backend/src/remote/activitypub/renderer/index.ts index 37e73d37b..8ec9f7ade 100644 --- a/packages/backend/src/remote/activitypub/renderer/index.ts +++ b/packages/backend/src/remote/activitypub/renderer/index.ts @@ -35,7 +35,6 @@ export const renderActivity = (x: any): IActivity | null => { value: 'schema:value', // Misskey misskey: 'https://misskey-hub.net/ns#', - '_misskey_content': 'misskey:_misskey_content', '_misskey_quote': 'misskey:_misskey_quote', '_misskey_reaction': 'misskey:_misskey_reaction', '_misskey_votes': 'misskey:_misskey_votes', diff --git a/packages/backend/src/remote/activitypub/renderer/note.ts b/packages/backend/src/remote/activitypub/renderer/note.ts index 6fd50c158..5ca251617 100644 --- a/packages/backend/src/remote/activitypub/renderer/note.ts +++ b/packages/backend/src/remote/activitypub/renderer/note.ts @@ -145,7 +145,6 @@ export default async function renderNote(note: Note, dive = true, isTalk = false attributedTo, summary, content, - _misskey_content: text, source: { content: text, mediaType: 'text/x.misskeymarkdown', From 68bc2e314bc5f55b452ac31ae410d8722bbd55d3 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 17:43:44 +0100 Subject: [PATCH 4/8] activitypub: remove _misskey_reaction property This property is duplicated by the `content` property so seems unnecessary. Changelog: Removed --- packages/backend/src/remote/activitypub/kernel/like.ts | 2 +- packages/backend/src/remote/activitypub/renderer/index.ts | 1 - packages/backend/src/remote/activitypub/renderer/like.ts | 1 - packages/backend/src/remote/activitypub/type.ts | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/remote/activitypub/kernel/like.ts b/packages/backend/src/remote/activitypub/kernel/like.ts index 76272eea7..9650312b3 100644 --- a/packages/backend/src/remote/activitypub/kernel/like.ts +++ b/packages/backend/src/remote/activitypub/kernel/like.ts @@ -11,7 +11,7 @@ export default async (actor: CacheableRemoteUser, activity: ILike) => { await extractEmojis(activity.tag || [], actor.host).catch(() => null); - return await createReaction(actor, note, activity._misskey_reaction || activity.content || activity.name).catch(e => { + return await createReaction(actor, note, activity.content || activity.name).catch(e => { if (e.id === '51c42bb4-931a-456b-bff7-e5a8a70dd298') { return 'skip: already reacted'; } else { diff --git a/packages/backend/src/remote/activitypub/renderer/index.ts b/packages/backend/src/remote/activitypub/renderer/index.ts index 8ec9f7ade..0ea143cda 100644 --- a/packages/backend/src/remote/activitypub/renderer/index.ts +++ b/packages/backend/src/remote/activitypub/renderer/index.ts @@ -36,7 +36,6 @@ export const renderActivity = (x: any): IActivity | null => { // Misskey misskey: 'https://misskey-hub.net/ns#', '_misskey_quote': 'misskey:_misskey_quote', - '_misskey_reaction': 'misskey:_misskey_reaction', '_misskey_votes': 'misskey:_misskey_votes', '_misskey_talk': 'misskey:_misskey_talk', 'isCat': 'misskey:isCat', diff --git a/packages/backend/src/remote/activitypub/renderer/like.ts b/packages/backend/src/remote/activitypub/renderer/like.ts index 3978bc961..a52d9c706 100644 --- a/packages/backend/src/remote/activitypub/renderer/like.ts +++ b/packages/backend/src/remote/activitypub/renderer/like.ts @@ -14,7 +14,6 @@ export const renderLike = async (noteReaction: NoteReaction, note: Note) => { actor: `${config.url}/users/${noteReaction.userId}`, object: note.uri ? note.uri : `${config.url}/notes/${noteReaction.noteId}`, content: reaction, - _misskey_reaction: reaction, } as any; if (reaction.startsWith(':')) { diff --git a/packages/backend/src/remote/activitypub/type.ts b/packages/backend/src/remote/activitypub/type.ts index 28868297d..a14133ddc 100644 --- a/packages/backend/src/remote/activitypub/type.ts +++ b/packages/backend/src/remote/activitypub/type.ts @@ -282,7 +282,7 @@ export interface IRemove extends IActivity { export interface ILike extends IActivity { type: 'Like' | 'EmojiReaction' | 'EmojiReact'; - _misskey_reaction?: string; + content?: string; } export interface IAnnounce extends IActivity { From b8796cb1faeca3f547759ba4709ce525ce23af1f Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 17:49:12 +0100 Subject: [PATCH 5/8] activitypub: remove _misskey_votes property This is a duplication of `replies.totalItems` and seems unnecessary, it is even only parsed by Misskey if the afforementioned property is not available. Changelog: Removed --- packages/backend/src/remote/activitypub/models/question.ts | 2 +- packages/backend/src/remote/activitypub/renderer/index.ts | 1 - packages/backend/src/remote/activitypub/renderer/question.ts | 1 - packages/backend/src/remote/activitypub/type.ts | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/backend/src/remote/activitypub/models/question.ts b/packages/backend/src/remote/activitypub/models/question.ts index 5d88e1d44..803acee66 100644 --- a/packages/backend/src/remote/activitypub/models/question.ts +++ b/packages/backend/src/remote/activitypub/models/question.ts @@ -23,7 +23,7 @@ export async function extractPollFromQuestion(source: string | IObject, resolver .map(x => x.name!); const votes = question[multiple ? 'anyOf' : 'oneOf']! - .map(x => x.replies && x.replies.totalItems || x._misskey_votes || 0); + .map(x => x.replies && x.replies.totalItems || 0); return { choices, diff --git a/packages/backend/src/remote/activitypub/renderer/index.ts b/packages/backend/src/remote/activitypub/renderer/index.ts index 0ea143cda..b66f766a2 100644 --- a/packages/backend/src/remote/activitypub/renderer/index.ts +++ b/packages/backend/src/remote/activitypub/renderer/index.ts @@ -36,7 +36,6 @@ export const renderActivity = (x: any): IActivity | null => { // Misskey misskey: 'https://misskey-hub.net/ns#', '_misskey_quote': 'misskey:_misskey_quote', - '_misskey_votes': 'misskey:_misskey_votes', '_misskey_talk': 'misskey:_misskey_talk', 'isCat': 'misskey:isCat', // vcard diff --git a/packages/backend/src/remote/activitypub/renderer/question.ts b/packages/backend/src/remote/activitypub/renderer/question.ts index d4d1b590a..a6116888a 100644 --- a/packages/backend/src/remote/activitypub/renderer/question.ts +++ b/packages/backend/src/remote/activitypub/renderer/question.ts @@ -11,7 +11,6 @@ export default async function renderQuestion(user: { id: User['id'] }, note: Not content: note.text || '', [poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({ name: text, - _misskey_votes: poll.votes[i], replies: { type: 'Collection', totalItems: poll.votes[i], diff --git a/packages/backend/src/remote/activitypub/type.ts b/packages/backend/src/remote/activitypub/type.ts index a14133ddc..b4d0499c5 100644 --- a/packages/backend/src/remote/activitypub/type.ts +++ b/packages/backend/src/remote/activitypub/type.ts @@ -171,7 +171,6 @@ export const isQuestion = (object: IObject): object is IQuestion => interface IQuestionChoice { name?: string; replies?: ICollection; - _misskey_votes?: number; } export interface ITombstone extends IObject { type: 'Tombstone'; From 3a7e8cfe5097f867d978e1a59f677030ee92c5f0 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 19:16:28 +0100 Subject: [PATCH 6/8] server: check instance description length limit Changelog: Fixed --- packages/backend/src/services/fetch-instance-metadata.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/services/fetch-instance-metadata.ts b/packages/backend/src/services/fetch-instance-metadata.ts index ad312c3c8..71eb3269a 100644 --- a/packages/backend/src/services/fetch-instance-metadata.ts +++ b/packages/backend/src/services/fetch-instance-metadata.ts @@ -246,19 +246,20 @@ async function getSiteName(info: NodeInfo | null, doc: DOMWindow['document'] | n async function getDescription(info: NodeInfo | null, doc: DOMWindow['document'] | null, manifest: Record | null): Promise { if (info && info.metadata) { - if (info.metadata.nodeDescription || info.metadata.description) { - return info.metadata.nodeDescription || info.metadata.description; + const description = info.metadata.nodeDescription || info.metadata.description; + if (description && description.length < 4096) { + return description; } } if (doc) { const meta = doc.querySelector('meta[name="description"]')?.getAttribute('content'); - if (meta) { + if (meta && meta.length < 4096) { return meta; } const og = doc.querySelector('meta[property="og:description"]')?.getAttribute('content'); - if (og) { + if (og && og.length < 4096) { return og; } } From c9d395961e56664075e130587064edd40c63d355 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 19:17:11 +0100 Subject: [PATCH 7/8] server: refactor packing User --- .../backend/src/models/repositories/user.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/backend/src/models/repositories/user.ts b/packages/backend/src/models/repositories/user.ts index 6a796b223..060bc0cd6 100644 --- a/packages/backend/src/models/repositories/user.ts +++ b/packages/backend/src/models/repositories/user.ts @@ -270,16 +270,14 @@ export const UserRepository = db.getRepository(User).extend({ const followingCount = profile == null ? null : (profile.ffVisibility === 'public') || isMe ? user.followingCount : - (profile.ffVisibility === 'followers') && (relation && relation.isFollowing) ? user.followingCount : + (profile.ffVisibility === 'followers') && relation?.isFollowing ? user.followingCount : null; const followersCount = profile == null ? null : (profile.ffVisibility === 'public') || isMe ? user.followersCount : - (profile.ffVisibility === 'followers') && (relation && relation.isFollowing) ? user.followersCount : + (profile.ffVisibility === 'followers') && relation?.isFollowing ? user.followersCount : null; - const falsy = opts.detail ? false : undefined; - const packed = { id: user.id, name: user.name, @@ -287,10 +285,10 @@ export const UserRepository = db.getRepository(User).extend({ host: user.host, avatarUrl: this.getAvatarUrlSync(user), avatarBlurhash: user.avatar?.blurhash || null, - isAdmin: user.isAdmin || falsy, - isModerator: user.isModerator || falsy, - isBot: user.isBot || falsy, - isCat: user.isCat || falsy, + isAdmin: user.isAdmin, + isModerator: user.isModerator, + isBot: user.isBot, + isCat: user.isCat, instance: !user.host ? undefined : userInstanceCache.fetch(user.host) .then(instance => !instance ? undefined : { name: instance.name, @@ -312,8 +310,8 @@ export const UserRepository = db.getRepository(User).extend({ bannerUrl: user.banner ? DriveFiles.getPublicUrl(user.banner, false) : null, bannerBlurhash: user.banner?.blurhash || null, isLocked: user.isLocked, - isSilenced: user.isSilenced || falsy, - isSuspended: user.isSuspended || falsy, + isSilenced: user.isSilenced, + isSuspended: user.isSuspended, description: profile!.description, location: profile!.location, birthday: profile!.birthday, @@ -369,7 +367,7 @@ export const UserRepository = db.getRepository(User).extend({ mutedInstances: profile!.mutedInstances, mutingNotificationTypes: profile!.mutingNotificationTypes, emailNotificationTypes: profile!.emailNotificationTypes, - showTimelineReplies: user.showTimelineReplies || falsy, + showTimelineReplies: user.showTimelineReplies, federateBlocks: user!.federateBlocks, } : {}), From 1ffa4b08e049e95f159b3128fde0fa184d42a3a4 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 19:25:51 +0100 Subject: [PATCH 8/8] client: reformat notification component who the hell is supposed to read this --- .../client/src/components/notification.vue | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/notification.vue b/packages/client/src/components/notification.vue index 233e99aad..43ceb38a4 100644 --- a/packages/client/src/components/notification.vue +++ b/packages/client/src/components/notification.vue @@ -63,10 +63,29 @@ - {{ i18n.ts.youGotNewFollower }}
- {{ i18n.ts.followRequestAccepted }} - {{ i18n.ts.receiveFollowRequest }}
|
- {{ i18n.ts.groupInvited }}: {{ notification.invitation.group.name }}
|
+ + {{ i18n.ts.youGotNewFollower }} +
+ +
+
+ + {{ i18n.ts.followRequestAccepted }} + + + {{ i18n.ts.receiveFollowRequest }} +
+ | + +
+
+ + {{ i18n.ts.groupInvited }}: {{ notification.invitation.group.name }} +
+ | + +
+