diff --git a/migration/1585772678853-ap-url.ts b/migration/1585772678853-ap-url.ts new file mode 100644 index 0000000000000000000000000000000000000000..622d0972766e170b0f0fd97fe3364c71daf90784 --- /dev/null +++ b/migration/1585772678853-ap-url.ts @@ -0,0 +1,15 @@ +/* tslint:disable:quotemark class-name indent */ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class apUrl1585772678853 implements MigrationInterface { + name = 'apUrl1585772678853' + + public async up(queryRunner: QueryRunner): Promise<any> { + await queryRunner.query(`ALTER TABLE "note" ADD "url" character varying(512)`, undefined); + } + + public async down(queryRunner: QueryRunner): Promise<any> { + await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "url"`, undefined); + } + +} diff --git a/src/client/components/note.vue b/src/client/components/note.vue index 48e37c33d3c2c34f69f2d17654da1fca31c3229a..07011ba50ff9cf79b11590cabd36da8d0d56417e 100644 --- a/src/client/components/note.vue +++ b/src/client/components/note.vue @@ -517,11 +517,11 @@ export default Vue.extend({ icon: faLink, text: this.$t('copyLink'), action: this.copyLink - }, this.appearNote.uri ? { + }, (this.appearNote.url || this.appearNote.uri) ? { icon: faExternalLinkSquareAlt, text: this.$t('showOnRemote'), action: () => { - window.open(this.appearNote.uri, '_blank'); + window.open(this.appearNote.url || this.appearNote.uri, '_blank'); } } : undefined, null, @@ -585,11 +585,11 @@ export default Vue.extend({ icon: faLink, text: this.$t('copyLink'), action: this.copyLink - }, this.appearNote.uri ? { + }, (this.appearNote.url || this.appearNote.uri) ? { icon: faExternalLinkSquareAlt, text: this.$t('showOnRemote'), action: () => { - window.open(this.appearNote.uri, '_blank'); + window.open(this.appearNote.url || this.appearNote.uri, '_blank'); } } : undefined] .filter(x => x !== undefined); diff --git a/src/client/pages/note.vue b/src/client/pages/note.vue index dbdf8c3d35f4451b30dc57efe4c0f3a81f4e1699..37c66833e970a0e34304543801563479481f4551 100644 --- a/src/client/pages/note.vue +++ b/src/client/pages/note.vue @@ -13,7 +13,7 @@ <x-notes v-if="showNext" ref="next" :pagination="next"/> <hr v-if="showNext"/> - <mk-remote-caution v-if="note.user.host != null" :href="note.uri" style="margin-bottom: var(--margin)"/> + <mk-remote-caution v-if="note.user.host != null" :href="note.url || note.uri" style="margin-bottom: var(--margin)"/> <x-note :note="note" :key="note.id" :detail="true"/> <div v-if="error"> <mk-error @retry="fetch()"/> diff --git a/src/models/entities/note.ts b/src/models/entities/note.ts index e6fbd4ce759da4817cbc460b38ae5366037badc4..79b6b5ab7db8bfea532193c425e473aedefe5e4b 100644 --- a/src/models/entities/note.ts +++ b/src/models/entities/note.ts @@ -112,6 +112,12 @@ export class Note { }) public uri: string | null; + @Column('varchar', { + length: 512, nullable: true, + comment: 'The human readable url of a note. it will be null when the note is local.' + }) + public url: string | null; + @Column('integer', { default: 0, select: false }) diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts index 73d7ad86ebf459b45bd654c8bc9c04399f508bd0..2510830489fb4394865333208a8f759a96a4499a 100644 --- a/src/models/repositories/note.ts +++ b/src/models/repositories/note.ts @@ -171,8 +171,8 @@ export class NoteRepository extends Repository<Note> { let text = note.text; - if (note.name && note.uri) { - text = `ã€${note.name}】\n${(note.text || '').trim()}\n${note.uri}`; + if (note.name && (note.url || note.uri)) { + text = `ã€${note.name}】\n${(note.text || '').trim()}\n\n${note.url || note.uri}`; } const packed = await awaitAll({ @@ -197,6 +197,7 @@ export class NoteRepository extends Repository<Note> { renoteId: note.renoteId, mentions: note.mentions.length > 0 ? note.mentions : undefined, uri: note.uri || undefined, + url: note.url || undefined, _featuredId_: (note as any)._featuredId_ || undefined, _prId_: (note as any)._prId_ || undefined, diff --git a/src/remote/activitypub/models/note.ts b/src/remote/activitypub/models/note.ts index 70ceb5e5038b272ee3fbdb6deae43407daee9125..55b5440e6bec8f9a85612d82bf27b59471166ccf 100644 --- a/src/remote/activitypub/models/note.ts +++ b/src/remote/activitypub/models/note.ts @@ -280,7 +280,8 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s apHashtags, apEmojis, poll, - uri: note.id + uri: note.id, + url: note.url, }, silent); } diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 60a5a5e69d79fe1c9babb81e0cba162342d8fa52..f506337924afe7a6fe8952386ba2cee1da8ea2c4 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -104,6 +104,7 @@ type Option = { apHashtags?: string[] | null; apEmojis?: string[] | null; uri?: string | null; + url?: string | null; app?: App | null; }; @@ -407,6 +408,7 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri }); if (data.uri != null) insert.uri = data.uri; + if (data.url != null) insert.url = data.url; // Append mentions data if (mentionedUsers.length > 0) {