mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-23 09:23:48 +01:00
Refactor
This commit is contained in:
parent
8e8a9175ad
commit
6113f7260c
25
src/remote/activitypub/act/undo/follow.ts
Normal file
25
src/remote/activitypub/act/undo/follow.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import parseAcct from '../../../../acct/parse';
|
||||||
|
import User from '../../../../models/user';
|
||||||
|
import config from '../../../../config';
|
||||||
|
import unfollow from '../../../../services/following/delete';
|
||||||
|
|
||||||
|
export default async (actor, activity): Promise<void> => {
|
||||||
|
const prefix = config.url + '/@';
|
||||||
|
const id = activity.object.id || activity.object;
|
||||||
|
|
||||||
|
if (!id.startsWith(prefix)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { username, host } = parseAcct(id.slice(prefix.length));
|
||||||
|
if (host !== null) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
const followee = await User.findOne({ username, host });
|
||||||
|
if (followee === null) {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
await unfollow(actor, followee, activity);
|
||||||
|
};
|
@ -1,4 +1,4 @@
|
|||||||
import unfollow from './unfollow';
|
import unfollow from './follow';
|
||||||
|
|
||||||
export default async (actor, activity): Promise<void> => {
|
export default async (actor, activity): Promise<void> => {
|
||||||
if ('actor' in activity && actor.account.uri !== activity.actor) {
|
if ('actor' in activity && actor.account.uri !== activity.actor) {
|
Loading…
Reference in New Issue
Block a user