1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-23 22:56:53 +09:00

Use url if available (#6214)

* Fix #6213

* other link

* fix
This commit is contained in:
MeiMei 2020-04-02 21:59:14 +09:00 committed by GitHub
parent 331305e6c7
commit 356225af14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 8 deletions

View File

@ -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);
}
}

View File

@ -517,11 +517,11 @@ export default Vue.extend({
icon: faLink, icon: faLink,
text: this.$t('copyLink'), text: this.$t('copyLink'),
action: this.copyLink action: this.copyLink
}, this.appearNote.uri ? { }, (this.appearNote.url || this.appearNote.uri) ? {
icon: faExternalLinkSquareAlt, icon: faExternalLinkSquareAlt,
text: this.$t('showOnRemote'), text: this.$t('showOnRemote'),
action: () => { action: () => {
window.open(this.appearNote.uri, '_blank'); window.open(this.appearNote.url || this.appearNote.uri, '_blank');
} }
} : undefined, } : undefined,
null, null,
@ -585,11 +585,11 @@ export default Vue.extend({
icon: faLink, icon: faLink,
text: this.$t('copyLink'), text: this.$t('copyLink'),
action: this.copyLink action: this.copyLink
}, this.appearNote.uri ? { }, (this.appearNote.url || this.appearNote.uri) ? {
icon: faExternalLinkSquareAlt, icon: faExternalLinkSquareAlt,
text: this.$t('showOnRemote'), text: this.$t('showOnRemote'),
action: () => { action: () => {
window.open(this.appearNote.uri, '_blank'); window.open(this.appearNote.url || this.appearNote.uri, '_blank');
} }
} : undefined] } : undefined]
.filter(x => x !== undefined); .filter(x => x !== undefined);

View File

@ -13,7 +13,7 @@
<x-notes v-if="showNext" ref="next" :pagination="next"/> <x-notes v-if="showNext" ref="next" :pagination="next"/>
<hr v-if="showNext"/> <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"/> <x-note :note="note" :key="note.id" :detail="true"/>
<div v-if="error"> <div v-if="error">
<mk-error @retry="fetch()"/> <mk-error @retry="fetch()"/>

View File

@ -112,6 +112,12 @@ export class Note {
}) })
public uri: string | null; 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', { @Column('integer', {
default: 0, select: false default: 0, select: false
}) })

View File

@ -171,8 +171,8 @@ export class NoteRepository extends Repository<Note> {
let text = note.text; let text = note.text;
if (note.name && note.uri) { if (note.name && (note.url || note.uri)) {
text = `${note.name}\n${(note.text || '').trim()}\n${note.uri}`; text = `${note.name}\n${(note.text || '').trim()}\n\n${note.url || note.uri}`;
} }
const packed = await awaitAll({ const packed = await awaitAll({
@ -197,6 +197,7 @@ export class NoteRepository extends Repository<Note> {
renoteId: note.renoteId, renoteId: note.renoteId,
mentions: note.mentions.length > 0 ? note.mentions : undefined, mentions: note.mentions.length > 0 ? note.mentions : undefined,
uri: note.uri || undefined, uri: note.uri || undefined,
url: note.url || undefined,
_featuredId_: (note as any)._featuredId_ || undefined, _featuredId_: (note as any)._featuredId_ || undefined,
_prId_: (note as any)._prId_ || undefined, _prId_: (note as any)._prId_ || undefined,

View File

@ -280,7 +280,8 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
apHashtags, apHashtags,
apEmojis, apEmojis,
poll, poll,
uri: note.id uri: note.id,
url: note.url,
}, silent); }, silent);
} }

View File

@ -104,6 +104,7 @@ type Option = {
apHashtags?: string[] | null; apHashtags?: string[] | null;
apEmojis?: string[] | null; apEmojis?: string[] | null;
uri?: string | null; uri?: string | null;
url?: string | null;
app?: App | 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.uri != null) insert.uri = data.uri;
if (data.url != null) insert.url = data.url;
// Append mentions data // Append mentions data
if (mentionedUsers.length > 0) { if (mentionedUsers.length > 0) {