Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

リモートフォローは必ず承認待ち状態を挟むように変更 #2606

Merged
merged 1 commit into from Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client/app/common/views/pages/follow.vue
Expand Up @@ -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
});
Expand Down
8 changes: 5 additions & 3 deletions src/client/app/desktop/views/components/follow-button.vue
Expand Up @@ -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;
}
},

Expand All @@ -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
});
Expand Down
4 changes: 3 additions & 1 deletion src/client/app/mobile/views/components/follow-button.vue
Expand Up @@ -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;
}
},

Expand All @@ -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
});
Expand Down
4 changes: 2 additions & 2 deletions src/models/user.ts
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions src/services/following/create.ts
Expand Up @@ -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({
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/services/following/requests/accept.ts
Expand Up @@ -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));
}
2 changes: 0 additions & 2 deletions src/services/following/requests/create.ts
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/services/following/requests/reject.ts
@@ -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)) {
Expand All @@ -21,4 +22,6 @@ export default async function(followee: IUser, follower: IUser) {
pendingReceivedFollowRequestsCount: -1
}
});

packUser(followee, follower).then(packed => publishUserStream(follower._id, 'unfollow', packed));
}