feat: Undo Accept (#7980)
* allow breaking of follow * send undo * delete by using reject follow
This commit is contained in:
		
							parent
							
								
									a82ff360c6
								
							
						
					
					
						commit
						f33ded3107
					
				
					 6 changed files with 136 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
import unfollow from '@/services/following/delete';
 | 
			
		||||
import cancelRequest from '@/services/following/requests/cancel';
 | 
			
		||||
import {IAccept} from '../../type';
 | 
			
		||||
import { IRemoteUser } from '@/models/entities/user';
 | 
			
		||||
import { Followings } from '@/models/index';
 | 
			
		||||
import DbResolver from '../../db-resolver';
 | 
			
		||||
 | 
			
		||||
export default async (actor: IRemoteUser, activity: IAccept): Promise<string> => {
 | 
			
		||||
	const dbResolver = new DbResolver();
 | 
			
		||||
 | 
			
		||||
	const follower = await dbResolver.getUserFromApId(activity.object);
 | 
			
		||||
	if (follower == null) {
 | 
			
		||||
		return `skip: follower not found`;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const following = await Followings.findOne({
 | 
			
		||||
		followerId: follower.id,
 | 
			
		||||
		followeeId: actor.id
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	if (following) {
 | 
			
		||||
		await unfollow(follower, actor);
 | 
			
		||||
		return `ok: unfollowed`;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return `skip: フォローされていない`;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -1,8 +1,9 @@
 | 
			
		|||
import { IRemoteUser } from '@/models/entities/user';
 | 
			
		||||
import { IUndo, isFollow, isBlock, isLike, isAnnounce, getApType } from '../../type';
 | 
			
		||||
import {IUndo, isFollow, isBlock, isLike, isAnnounce, getApType, isAccept} from '../../type';
 | 
			
		||||
import unfollow from './follow';
 | 
			
		||||
import unblock from './block';
 | 
			
		||||
import undoLike from './like';
 | 
			
		||||
import undoAccept from './accept';
 | 
			
		||||
import { undoAnnounce } from './announce';
 | 
			
		||||
import Resolver from '../../resolver';
 | 
			
		||||
import { apLogger } from '../../logger';
 | 
			
		||||
| 
						 | 
				
			
			@ -29,6 +30,7 @@ export default async (actor: IRemoteUser, activity: IUndo): Promise<string> => {
 | 
			
		|||
	if (isBlock(object)) return await unblock(actor, object);
 | 
			
		||||
	if (isLike(object)) return await undoLike(actor, object);
 | 
			
		||||
	if (isAnnounce(object)) return await undoAnnounce(actor, object);
 | 
			
		||||
	if (isAccept(object)) return await undoAccept(actor, object);
 | 
			
		||||
 | 
			
		||||
	return `skip: unknown object type ${getApType(object)}`;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue