activitypub: properly render CW only quotes
Changelog: Fixed
This commit is contained in:
parent
0bb4a6af50
commit
85a68a5eee
3 changed files with 6 additions and 14 deletions
|
@ -1,8 +1,9 @@
|
||||||
import { Note } from '@/models/entities/note.js';
|
import { Note } from '@/models/entities/note.js';
|
||||||
|
|
||||||
export function isPureRenote(note: Note): note is Note & { renoteId: string, text: null, fileIds: null | never[], hasPoll: false } {
|
export function isPureRenote(note: Note): note is Note & { renoteId: string, text: null, cw: null, fileIds: null | never[], hasPoll: false } {
|
||||||
return note.renoteId != null
|
return note.renoteId != null
|
||||||
&& note.text == null
|
&& note.text == null
|
||||||
|
&& note.cw == null
|
||||||
&& (
|
&& (
|
||||||
note.fileIds == null
|
note.fileIds == null
|
||||||
|| note.fileIds.length === 0
|
|| note.fileIds.length === 0
|
||||||
|
|
|
@ -102,7 +102,7 @@ export default async (ctx: Router.RouterContext) => {
|
||||||
export async function packActivity(note: Note): Promise<any> {
|
export async function packActivity(note: Note): Promise<any> {
|
||||||
if (isPureRenote(note)) {
|
if (isPureRenote(note)) {
|
||||||
const renote = await Notes.findOneByOrFail({ id: note.renoteId });
|
const renote = await Notes.findOneByOrFail({ id: note.renoteId });
|
||||||
return renderAnnounce(renote.uri ? renote.uri : `${config.url}/notes/${renote.id}`, note);
|
return renderAnnounce(renote.uri ?? `${config.url}/notes/${renote.id}`, note);
|
||||||
} else {
|
} else {
|
||||||
return renderCreate(await renderNote(note, false), note);
|
return renderCreate(await renderNote(note, false), note);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import { Cache } from '@/misc/cache.js';
|
||||||
import { UserProfile } from '@/models/entities/user-profile.js';
|
import { UserProfile } from '@/models/entities/user-profile.js';
|
||||||
import { getActiveWebhooks } from '@/misc/webhook-cache.js';
|
import { getActiveWebhooks } from '@/misc/webhook-cache.js';
|
||||||
import { IActivity } from '@/remote/activitypub/type.js';
|
import { IActivity } from '@/remote/activitypub/type.js';
|
||||||
|
import { packActivity } from '@/server/activitypub/outbox.js';
|
||||||
import { MINUTE } from '@/const.js';
|
import { MINUTE } from '@/const.js';
|
||||||
import { updateHashtags } from '../update-hashtag.js';
|
import { updateHashtags } from '../update-hashtag.js';
|
||||||
import { registerOrFetchInstanceDoc } from '../register-or-fetch-instance-doc.js';
|
import { registerOrFetchInstanceDoc } from '../register-or-fetch-instance-doc.js';
|
||||||
|
@ -428,9 +429,9 @@ export default async (user: { id: User['id']; username: User['username']; host:
|
||||||
});
|
});
|
||||||
|
|
||||||
//#region AP deliver
|
//#region AP deliver
|
||||||
if (Users.isLocalUser(user)) {
|
if (Users.isLocalUser(user) && !data.localOnly) {
|
||||||
(async () => {
|
(async () => {
|
||||||
const noteActivity = await renderNoteOrRenoteActivity(data, note);
|
const noteActivity = renderActivity(await packActivity(note));
|
||||||
const dm = new DeliverManager(user, noteActivity);
|
const dm = new DeliverManager(user, noteActivity);
|
||||||
|
|
||||||
// Delivered to remote users who have been mentioned
|
// Delivered to remote users who have been mentioned
|
||||||
|
@ -487,16 +488,6 @@ export default async (user: { id: User['id']; username: User['username']; host:
|
||||||
index(note);
|
index(note);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function renderNoteOrRenoteActivity(data: Option, note: Note): Promise<IActivity | null> {
|
|
||||||
if (data.localOnly) return null;
|
|
||||||
|
|
||||||
const content = data.renote && data.text == null && data.poll == null && (data.files == null || data.files.length === 0)
|
|
||||||
? renderAnnounce(data.renote.uri ? data.renote.uri : `${config.url}/notes/${data.renote.id}`, note)
|
|
||||||
: renderCreate(await renderNote(note, false), note);
|
|
||||||
|
|
||||||
return renderActivity(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
function incRenoteCount(renote: Note): void {
|
function incRenoteCount(renote: Note): void {
|
||||||
Notes.createQueryBuilder().update()
|
Notes.createQueryBuilder().update()
|
||||||
.set({
|
.set({
|
||||||
|
|
Loading…
Reference in a new issue