Fix following from Preroma does not complete (#2905)
* In Follow Accept/Reject, send previous received id * In Follow Accept/Reject, send Activity.actor
This commit is contained in:
parent
2ad2779096
commit
49dbd7f9d2
|
@ -12,6 +12,7 @@ export type IFollowRequest = {
|
|||
createdAt: Date;
|
||||
followeeId: mongo.ObjectID;
|
||||
followerId: mongo.ObjectID;
|
||||
requestId?: string; // id of Follow Activity
|
||||
|
||||
// 非正規化
|
||||
_followee: {
|
||||
|
|
|
@ -23,5 +23,5 @@ export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
|
|||
throw new Error('フォローしようとしているユーザーはローカルユーザーではありません');
|
||||
}
|
||||
|
||||
await follow(actor, followee);
|
||||
await follow(actor, followee, activity.id);
|
||||
};
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
export default (object: any) => ({
|
||||
import config from '../../../config';
|
||||
import { ILocalUser } from '../../../models/user';
|
||||
|
||||
export default (object: any, user: ILocalUser) => ({
|
||||
type: 'Accept',
|
||||
actor: `${config.url}/users/${user._id}`,
|
||||
object
|
||||
});
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
import config from '../../../config';
|
||||
import { IUser, isLocalUser } from '../../../models/user';
|
||||
|
||||
export default (follower: IUser, followee: IUser) => ({
|
||||
export default (follower: IUser, followee: IUser, requestId?: string) => {
|
||||
const follow = {
|
||||
type: 'Follow',
|
||||
actor: isLocalUser(follower) ? `${config.url}/users/${follower._id}` : follower.uri,
|
||||
object: isLocalUser(followee) ? `${config.url}/users/${followee._id}` : followee.uri
|
||||
});
|
||||
} as any;
|
||||
|
||||
if (requestId) follow.id = requestId;
|
||||
|
||||
return follow;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
export default (object: any) => ({
|
||||
import config from '../../../config';
|
||||
import { ILocalUser } from '../../../models/user';
|
||||
|
||||
export default (object: any, user: ILocalUser) => ({
|
||||
type: 'Reject',
|
||||
actor: `${config.url}/users/${user._id}`,
|
||||
object
|
||||
});
|
||||
|
|
|
@ -10,13 +10,13 @@ import renderAccept from '../../remote/activitypub/renderer/accept';
|
|||
import { deliver } from '../../queue';
|
||||
import createFollowRequest from './requests/create';
|
||||
|
||||
export default async function(follower: IUser, followee: IUser) {
|
||||
export default async function(follower: IUser, followee: IUser, requestId?: string) {
|
||||
// フォロー対象が鍵アカウントである or
|
||||
// フォロワーがBotであり、フォロー対象がBotからのフォローに慎重である or
|
||||
// フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである
|
||||
// 上記のいずれかに当てはまる場合はすぐフォローせずにフォローリクエストを発行しておく
|
||||
if (followee.isLocked || (followee.carefulBot && follower.isBot) || (isLocalUser(follower) && isRemoteUser(followee))) {
|
||||
await createFollowRequest(follower, followee);
|
||||
await createFollowRequest(follower, followee, requestId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ export default async function(follower: IUser, followee: IUser) {
|
|||
}
|
||||
|
||||
if (isRemoteUser(follower) && isLocalUser(followee)) {
|
||||
const content = pack(renderAccept(renderFollow(follower, followee)));
|
||||
const content = pack(renderAccept(renderFollow(follower, followee, requestId), followee));
|
||||
deliver(followee, content, follower.inbox);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,12 @@ export default async function(followee: IUser, follower: IUser) {
|
|||
});
|
||||
|
||||
if (isRemoteUser(follower)) {
|
||||
const content = pack(renderAccept(renderFollow(follower, followee)));
|
||||
const request = await FollowRequest.findOne({
|
||||
followeeId: followee._id,
|
||||
followerId: follower._id
|
||||
});
|
||||
|
||||
const content = pack(renderAccept(renderFollow(follower, followee, request.requestId), followee as ILocalUser));
|
||||
deliver(followee as ILocalUser, content, follower.inbox);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,12 @@ import renderFollow from '../../../remote/activitypub/renderer/follow';
|
|||
import { deliver } from '../../../queue';
|
||||
import FollowRequest from '../../../models/follow-request';
|
||||
|
||||
export default async function(follower: IUser, followee: IUser) {
|
||||
export default async function(follower: IUser, followee: IUser, requestId?: string) {
|
||||
await FollowRequest.insert({
|
||||
createdAt: new Date(),
|
||||
followerId: follower._id,
|
||||
followeeId: followee._id,
|
||||
requestId,
|
||||
|
||||
// 非正規化
|
||||
_follower: {
|
||||
|
|
|
@ -8,7 +8,12 @@ import { publishMainStream } from '../../../stream';
|
|||
|
||||
export default async function(followee: IUser, follower: IUser) {
|
||||
if (isRemoteUser(follower)) {
|
||||
const content = pack(renderReject(renderFollow(follower, followee)));
|
||||
const request = await FollowRequest.findOne({
|
||||
followeeId: followee._id,
|
||||
followerId: follower._id
|
||||
});
|
||||
|
||||
const content = pack(renderReject(renderFollow(follower, followee, request.requestId), followee as ILocalUser));
|
||||
deliver(followee as ILocalUser, content, follower.inbox);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue