From 5ddb047794bb3aaef250c15dfbae56872faedfd9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 8 Apr 2018 05:02:50 +0900 Subject: [PATCH] Fix bugs --- src/remote/activitypub/renderer/follow.ts | 6 ++--- src/remote/activitypub/resolve-person.ts | 12 ++++------ src/remote/request.ts | 2 +- src/server/api/endpoints/following/create.ts | 2 +- src/server/api/endpoints/i/update.ts | 24 ++++--------------- .../endpoints/users/{posts.ts => notes.ts} | 0 6 files changed, 14 insertions(+), 32 deletions(-) rename src/server/api/endpoints/users/{posts.ts => notes.ts} (100%) diff --git a/src/remote/activitypub/renderer/follow.ts b/src/remote/activitypub/renderer/follow.ts index 0a1ae1a4b2..89993d9458 100644 --- a/src/remote/activitypub/renderer/follow.ts +++ b/src/remote/activitypub/renderer/follow.ts @@ -1,8 +1,8 @@ import config from '../../../config'; -import { IRemoteUser } from '../../../models/user'; +import { IRemoteUser, ILocalUser } from '../../../models/user'; -export default ({ username }, followee: IRemoteUser) => ({ +export default (follower: ILocalUser, followee: IRemoteUser) => ({ type: 'Follow', - actor: `${config.url}/@${username}`, + actor: `${config.url}/@${follower.username}`, object: followee.uri }); diff --git a/src/remote/activitypub/resolve-person.ts b/src/remote/activitypub/resolve-person.ts index ac0900307f..ddb8d68715 100644 --- a/src/remote/activitypub/resolve-person.ts +++ b/src/remote/activitypub/resolve-person.ts @@ -66,14 +66,12 @@ export default async (value, verifier?: string) => { usernameLower: object.preferredUsername.toLowerCase(), host, hostLower, - account: { - publicKey: { - id: object.publicKey.id, - publicKeyPem: object.publicKey.publicKeyPem - }, - inbox: object.inbox, - uri: id, + publicKey: { + id: object.publicKey.id, + publicKeyPem: object.publicKey.publicKeyPem }, + inbox: object.inbox, + uri: id }); const [avatarId, bannerId] = (await Promise.all([ diff --git a/src/remote/request.ts b/src/remote/request.ts index a0c69cf4ef..81e7c05c73 100644 --- a/src/remote/request.ts +++ b/src/remote/request.ts @@ -8,7 +8,7 @@ import { ILocalUser } from '../models/user'; const log = debug('misskey:activitypub:deliver'); -export default (user: ILocalUser, url, object) => new Promise((resolve, reject) => { +export default (user: ILocalUser, url: string, object) => new Promise((resolve, reject) => { log(`--> ${url}`); const { protocol, hostname, port, pathname, search } = new URL(url); diff --git a/src/server/api/endpoints/following/create.ts b/src/server/api/endpoints/following/create.ts index d3cc549ca7..0a642f50b2 100644 --- a/src/server/api/endpoints/following/create.ts +++ b/src/server/api/endpoints/following/create.ts @@ -31,7 +31,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { }, { fields: { data: false, - 'profile': false + profile: false } }); diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index a8caa0ebc4..36be2774f6 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -4,7 +4,6 @@ import $ from 'cafy'; import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user'; import event from '../../../../publishers/stream'; -import config from '../../../../config'; /** * Update myself @@ -17,7 +16,7 @@ import config from '../../../../config'; */ module.exports = async (params, user, _, isSecure) => new Promise(async (res, rej) => { // Get 'name' parameter - const [name, nameErr] = $(params.name).optional.string().pipe(isValidName).$; + const [name, nameErr] = $(params.name).optional.nullable.string().pipe(isValidName).$; if (nameErr) return rej('invalid name param'); if (name) user.name = name; @@ -62,9 +61,9 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re description: user.description, avatarId: user.avatarId, bannerId: user.bannerId, - 'profile': user.profile, - 'isBot': user.isBot, - 'settings': user.settings + profile: user.profile, + isBot: user.isBot, + settings: user.settings } }); @@ -79,19 +78,4 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re // Publish i updated event event(user._id, 'i_updated', iObj); - - // Update search index - if (config.elasticsearch.enable) { - const es = require('../../../db/elasticsearch'); - - es.index({ - index: 'misskey', - type: 'user', - id: user._id.toString(), - body: { - name: user.name, - bio: user.bio - } - }); - } }); diff --git a/src/server/api/endpoints/users/posts.ts b/src/server/api/endpoints/users/notes.ts similarity index 100% rename from src/server/api/endpoints/users/posts.ts rename to src/server/api/endpoints/users/notes.ts