mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 18:43:08 +02:00
Fix remote follow (#2606)
This commit is contained in:
parent
a0735b0e7a
commit
eaec936fa6
8 changed files with 18 additions and 16 deletions
|
@ -83,7 +83,7 @@ export default Vue.extend({
|
|||
userId: this.user.id
|
||||
});
|
||||
} else {
|
||||
if (this.user.isLocked && this.user.hasPendingFollowRequestFromYou) {
|
||||
if (this.user.hasPendingFollowRequestFromYou) {
|
||||
this.user = await (this as any).api('following/requests/cancel', {
|
||||
userId: this.user.id
|
||||
});
|
||||
|
|
|
@ -55,13 +55,15 @@ export default Vue.extend({
|
|||
methods: {
|
||||
onFollow(user) {
|
||||
if (user.id == this.u.id) {
|
||||
this.user.isFollowing = user.isFollowing;
|
||||
this.u.isFollowing = user.isFollowing;
|
||||
this.u.hasPendingFollowRequestFromYou = user.hasPendingFollowRequestFromYou;
|
||||
}
|
||||
},
|
||||
|
||||
onUnfollow(user) {
|
||||
if (user.id == this.u.id) {
|
||||
this.user.isFollowing = user.isFollowing;
|
||||
this.u.isFollowing = user.isFollowing;
|
||||
this.u.hasPendingFollowRequestFromYou = user.hasPendingFollowRequestFromYou;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -74,7 +76,7 @@ export default Vue.extend({
|
|||
userId: this.u.id
|
||||
});
|
||||
} else {
|
||||
if (this.u.isLocked && this.u.hasPendingFollowRequestFromYou) {
|
||||
if (this.u.hasPendingFollowRequestFromYou) {
|
||||
this.u = await (this as any).api('following/requests/cancel', {
|
||||
userId: this.u.id
|
||||
});
|
||||
|
|
|
@ -48,12 +48,14 @@ export default Vue.extend({
|
|||
onFollow(user) {
|
||||
if (user.id == this.u.id) {
|
||||
this.u.isFollowing = user.isFollowing;
|
||||
this.u.hasPendingFollowRequestFromYou = user.hasPendingFollowRequestFromYou;
|
||||
}
|
||||
},
|
||||
|
||||
onUnfollow(user) {
|
||||
if (user.id == this.u.id) {
|
||||
this.u.isFollowing = user.isFollowing;
|
||||
this.u.hasPendingFollowRequestFromYou = user.hasPendingFollowRequestFromYou;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -66,7 +68,7 @@ export default Vue.extend({
|
|||
userId: this.u.id
|
||||
});
|
||||
} else {
|
||||
if (this.u.isLocked && this.u.hasPendingFollowRequestFromYou) {
|
||||
if (this.u.hasPendingFollowRequestFromYou) {
|
||||
this.u = await (this as any).api('following/requests/cancel', {
|
||||
userId: this.u.id
|
||||
});
|
||||
|
|
|
@ -432,10 +432,10 @@ export const pack = (
|
|||
followerId: _user.id,
|
||||
followeeId: meId
|
||||
}),
|
||||
_user.isLocked ? FollowRequest.findOne({
|
||||
FollowRequest.findOne({
|
||||
followerId: meId,
|
||||
followeeId: _user.id
|
||||
}) : Promise.resolve(null),
|
||||
}),
|
||||
FollowRequest.findOne({
|
||||
followerId: _user.id,
|
||||
followeeId: meId
|
||||
|
|
|
@ -11,7 +11,7 @@ import { deliver } from '../../queue';
|
|||
import createFollowRequest from './requests/create';
|
||||
|
||||
export default async function(follower: IUser, followee: IUser) {
|
||||
if (followee.isLocked) {
|
||||
if (followee.isLocked || isLocalUser(follower) && isRemoteUser(followee)) {
|
||||
await createFollowRequest(follower, followee);
|
||||
} else {
|
||||
const following = await Following.insert({
|
||||
|
@ -72,11 +72,6 @@ export default async function(follower: IUser, followee: IUser) {
|
|||
notify(followee._id, follower._id, 'follow');
|
||||
}
|
||||
|
||||
if (isLocalUser(follower) && isRemoteUser(followee)) {
|
||||
const content = pack(renderFollow(follower, followee));
|
||||
deliver(follower, content, followee.inbox);
|
||||
}
|
||||
|
||||
if (isRemoteUser(follower) && isLocalUser(followee)) {
|
||||
const content = pack(renderAccept(renderFollow(follower, followee)));
|
||||
deliver(followee, content, follower.inbox);
|
||||
|
|
|
@ -75,4 +75,6 @@ export default async function(followee: IUser, follower: IUser) {
|
|||
packUser(followee, followee, {
|
||||
detail: true
|
||||
}).then(packed => publishUserStream(followee._id, 'meUpdated', packed));
|
||||
|
||||
packUser(followee, follower).then(packed => publishUserStream(follower._id, 'follow', packed));
|
||||
}
|
||||
|
|
|
@ -7,8 +7,6 @@ import { deliver } from '../../../queue';
|
|||
import FollowRequest from '../../../models/follow-request';
|
||||
|
||||
export default async function(follower: IUser, followee: IUser) {
|
||||
if (!followee.isLocked) throw '対象のアカウントは鍵アカウントではありません';
|
||||
|
||||
await FollowRequest.insert({
|
||||
createdAt: new Date(),
|
||||
followerId: follower._id,
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import User, { IUser, isRemoteUser, ILocalUser } from '../../../models/user';
|
||||
import User, { IUser, isRemoteUser, ILocalUser, pack as packUser } from '../../../models/user';
|
||||
import FollowRequest from '../../../models/follow-request';
|
||||
import pack from '../../../remote/activitypub/renderer';
|
||||
import renderFollow from '../../../remote/activitypub/renderer/follow';
|
||||
import renderReject from '../../../remote/activitypub/renderer/reject';
|
||||
import { deliver } from '../../../queue';
|
||||
import { publishUserStream } from '../../../stream';
|
||||
|
||||
export default async function(followee: IUser, follower: IUser) {
|
||||
if (isRemoteUser(follower)) {
|
||||
|
@ -21,4 +22,6 @@ export default async function(followee: IUser, follower: IUser) {
|
|||
pendingReceivedFollowRequestsCount: -1
|
||||
}
|
||||
});
|
||||
|
||||
packUser(followee, follower).then(packed => publishUserStream(follower._id, 'unfollow', packed));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue