summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/act
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-08 15:15:22 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-08 15:15:22 +0900
commite63f884bc6ba89902e2efd20f1c6d8939f7c4270 (patch)
tree3293c8bf97510be5eb86a2c5f4f119035a790c59 /src/remote/activitypub/act
parentMerge pull request #1415 from syuilo/greenkeeper/html-minifier-3.5.14 (diff)
downloadmisskey-e63f884bc6ba89902e2efd20f1c6d8939f7c4270.tar.gz
misskey-e63f884bc6ba89902e2efd20f1c6d8939f7c4270.tar.bz2
misskey-e63f884bc6ba89902e2efd20f1c6d8939f7c4270.zip
Use id in uri instead of username
Diffstat (limited to 'src/remote/activitypub/act')
-rw-r--r--src/remote/activitypub/act/follow.ts16
-rw-r--r--src/remote/activitypub/act/undo/follow.ts18
2 files changed, 15 insertions, 19 deletions
diff --git a/src/remote/activitypub/act/follow.ts b/src/remote/activitypub/act/follow.ts
index 236886dc60..6a8b5a1bec 100644
--- a/src/remote/activitypub/act/follow.ts
+++ b/src/remote/activitypub/act/follow.ts
@@ -1,25 +1,23 @@
-import parseAcct from '../../../acct/parse';
import User, { IRemoteUser } from '../../../models/user';
import config from '../../../config';
import follow from '../../../services/following/create';
import { IFollow } from '../type';
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
- const prefix = config.url + '/@';
const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
- if (!id.startsWith(prefix)) {
+ if (!id.startsWith(config.url + '/')) {
return null;
}
- const { username, host } = parseAcct(id.slice(prefix.length));
- if (host !== null) {
- throw new Error();
- }
+ const followee = await User.findOne({ _id: id.split('/').pop() });
- const followee = await User.findOne({ username, host });
if (followee === null) {
- throw new Error();
+ throw new Error('followee not found');
+ }
+
+ if (followee.host != null) {
+ throw new Error('フォローしようとしているユーザーはローカルユーザーではありません');
}
await follow(actor, followee, activity);
diff --git a/src/remote/activitypub/act/undo/follow.ts b/src/remote/activitypub/act/undo/follow.ts
index fcf27c9507..a85cb0305d 100644
--- a/src/remote/activitypub/act/undo/follow.ts
+++ b/src/remote/activitypub/act/undo/follow.ts
@@ -1,25 +1,23 @@
-import parseAcct from '../../../../acct/parse';
import User, { IRemoteUser } from '../../../../models/user';
import config from '../../../../config';
import unfollow from '../../../../services/following/delete';
import { IFollow } from '../../type';
export default async (actor: IRemoteUser, activity: IFollow): Promise<void> => {
- const prefix = config.url + '/@';
- const id = typeof activity == 'string' ? activity : activity.id;
+ const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
- if (!id.startsWith(prefix)) {
+ if (!id.startsWith(config.url + '/')) {
return null;
}
- const { username, host } = parseAcct(id.slice(prefix.length));
- if (host !== null) {
- throw new Error();
- }
+ const followee = await User.findOne({ _id: id.split('/').pop() });
- const followee = await User.findOne({ username, host });
if (followee === null) {
- throw new Error();
+ throw new Error('followee not found');
+ }
+
+ if (followee.host != null) {
+ throw new Error('フォロー解除しようとしているユーザーはローカルユーザーではありません');
}
await unfollow(actor, followee, activity);