Use id in uri instead of username
This commit is contained in:
parent
1fced8a59b
commit
e63f884bc6
14 changed files with 52 additions and 87 deletions
|
|
@ -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() });
|
||||
|
||||
if (followee === null) {
|
||||
throw new Error('followee not found');
|
||||
}
|
||||
|
||||
const followee = await User.findOne({ username, host });
|
||||
if (followee === null) {
|
||||
throw new Error();
|
||||
if (followee.host != null) {
|
||||
throw new Error('フォローしようとしているユーザーはローカルユーザーではありません');
|
||||
}
|
||||
|
||||
await follow(actor, followee, activity);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue