summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/backend/migration/1741424411879-user-featured-fixup.js26
-rw-r--r--packages/backend/src/core/activitypub/models/ApPersonService.ts2
2 files changed, 27 insertions, 1 deletions
diff --git a/packages/backend/migration/1741424411879-user-featured-fixup.js b/packages/backend/migration/1741424411879-user-featured-fixup.js
new file mode 100644
index 0000000000..5643a328f0
--- /dev/null
+++ b/packages/backend/migration/1741424411879-user-featured-fixup.js
@@ -0,0 +1,26 @@
+/*
+ * SPDX-FileCopyrightText: syuilo and misskey-project
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+export class UserFeaturedFixup1741424411879 {
+ name = 'UserFeaturedFixup1741424411879'
+
+ async up(queryRunner) {
+ await queryRunner.query(`CREATE OR REPLACE FUNCTION pg_temp.extract_ap_id(text) RETURNS text AS $$
+ SELECT
+ CASE
+ WHEN $1 ~ '^https?://' THEN $1
+ WHEN $1 LIKE '{%' THEN COALESCE(jsonb_extract_path_text($1::jsonb, 'id'), null)
+ ELSE null
+ END;
+ $$ LANGUAGE sql IMMUTABLE;`);
+
+ // "host" is NOT NULL is not needed but just in case add it to prevent overwriting irreplaceable data
+ await queryRunner.query(`UPDATE "user" SET "featured" = pg_temp.extract_ap_id("featured") WHERE "host" IS NOT NULL`);
+ }
+
+ async down(queryRunner) {
+ // fixup migration, no down migration
+ }
+}
diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts
index 879f1922ca..e52078ed0f 100644
--- a/packages/backend/src/core/activitypub/models/ApPersonService.ts
+++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts
@@ -560,7 +560,7 @@ export class ApPersonService implements OnModuleInit {
inbox: person.inbox,
sharedInbox: person.sharedInbox ?? person.endpoints?.sharedInbox ?? null,
followersUri: person.followers ? getApId(person.followers) : undefined,
- featured: person.featured,
+ featured: person.featured ? getApId(person.featured) : undefined,
emojis: emojiNames,
name: truncate(person.name, nameLength),
tags,