mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-23 21:23:08 +02:00
parent
3ef6305c76
commit
c033464b92
3 changed files with 34 additions and 2 deletions
16
src/remote/activitypub/kernel/undo/announce.ts
Normal file
16
src/remote/activitypub/kernel/undo/announce.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { Notes } from '../../../../models';
|
||||
import { IRemoteUser } from '../../../../models/entities/user';
|
||||
import { IAnnounce, getApId } from '../../type';
|
||||
import deleteNote from '../../../../services/note/delete';
|
||||
|
||||
export const undoAnnounce = async (actor: IRemoteUser, activity: IAnnounce): Promise<void> => {
|
||||
const uri = getApId(activity);
|
||||
|
||||
const note = await Notes.findOne({
|
||||
uri
|
||||
});
|
||||
|
||||
if (!note) return;
|
||||
|
||||
await deleteNote(actor, note);
|
||||
};
|
|
@ -1,8 +1,9 @@
|
|||
import { IRemoteUser } from '../../../../models/entities/user';
|
||||
import { IUndo, IFollow, IBlock, ILike } from '../../type';
|
||||
import { IUndo, IFollow, IBlock, ILike, IAnnounce } from '../../type';
|
||||
import unfollow from './follow';
|
||||
import unblock from './block';
|
||||
import undoLike from './like';
|
||||
import { undoAnnounce } from './announce';
|
||||
import Resolver from '../../resolver';
|
||||
import { apLogger } from '../../logger';
|
||||
|
||||
|
@ -38,5 +39,8 @@ export default async (actor: IRemoteUser, activity: IUndo): Promise<void> => {
|
|||
case 'Like':
|
||||
undoLike(actor, object as ILike);
|
||||
break;
|
||||
case 'Announce':
|
||||
undoAnnounce(actor, object as IAnnounce);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { publishNoteStream } from '../stream';
|
||||
import renderDelete from '../../remote/activitypub/renderer/delete';
|
||||
import renderAnnounce from '../../remote/activitypub/renderer/announce';
|
||||
import renderUndo from '../../remote/activitypub/renderer/undo';
|
||||
import { renderActivity } from '../../remote/activitypub/renderer';
|
||||
import { deliver } from '../../queue';
|
||||
import renderTombstone from '../../remote/activitypub/renderer/tombstone';
|
||||
|
@ -35,7 +37,17 @@ export default async function(user: User, note: Note, quiet = false) {
|
|||
|
||||
//#region ローカルの投稿なら削除アクティビティを配送
|
||||
if (Users.isLocalUser(user)) {
|
||||
const content = renderActivity(renderDelete(renderTombstone(`${config.url}/notes/${note.id}`), user));
|
||||
let renote: Note | undefined;
|
||||
|
||||
if (note.renoteId && note.text == null && !note.hasPoll && (note.fileIds == null || note.fileIds.length == 0)) {
|
||||
renote = await Notes.findOne({
|
||||
id: note.renoteId
|
||||
});
|
||||
}
|
||||
|
||||
const content = renderActivity(renote
|
||||
? renderUndo(renderAnnounce(renote.uri || `${config.url}/notes/${renote.id}`, note), user)
|
||||
: renderDelete(renderTombstone(`${config.url}/notes/${note.id}`), user));
|
||||
|
||||
const queue: string[] = [];
|
||||
|
||||
|
|
Loading…
Reference in a new issue