diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml
index 01b1dfa2c4..1735376b2a 100644
--- a/locales/ja-JP.yml
+++ b/locales/ja-JP.yml
@@ -1280,6 +1280,8 @@ admin/views/users.vue:
unverify: "公式アカウントを解除する"
unverify-confirm: "公式アカウントを解除しますか?"
unverified: "公式アカウントを解除しました"
+ update-remote-user: "リモートユーザー情報の更新"
+ remote-user-updated: "リモートユーザー情報を更新しました"
users:
title: "ユーザー"
sort:
diff --git a/src/client/app/admin/views/users.vue b/src/client/app/admin/views/users.vue
index 6b829a2f8d..09d074eee2 100644
--- a/src/client/app/admin/views/users.vue
+++ b/src/client/app/admin/views/users.vue
@@ -20,6 +20,7 @@
{{ $t('suspend') }}
{{ $t('unsuspend') }}
+ {{ $t('update-remote-user') }}
@@ -65,7 +66,7 @@
import Vue from 'vue';
import i18n from '../../i18n';
import parseAcct from "../../../../misc/acct/parse";
-import { faCertificate, faUsers, faTerminal, faSearch, faKey } from '@fortawesome/free-solid-svg-icons';
+import { faCertificate, faUsers, faTerminal, faSearch, faKey, faSync } from '@fortawesome/free-solid-svg-icons';
import { faSnowflake } from '@fortawesome/free-regular-svg-icons';
import XUser from './users.user.vue';
@@ -89,7 +90,7 @@ export default Vue.extend({
offset: 0,
users: [],
existMore: false,
- faTerminal, faCertificate, faUsers, faSnowflake, faSearch, faKey
+ faTerminal, faCertificate, faUsers, faSnowflake, faSearch, faKey, faSync
};
},
@@ -265,6 +266,17 @@ export default Vue.extend({
this.refreshUser();
},
+ async updateRemoteUser() {
+ this.$root.api('admin/update-remote-user', { userId: this.user._id }).then(res => {
+ this.$root.dialog({
+ type: 'success',
+ text: this.$t('remote-user-updated')
+ });
+ });
+
+ this.refreshUser();
+ },
+
async getConfirmed(text: string): Promise {
const confirm = await this.$root.dialog({
type: 'warning',
diff --git a/src/server/api/common/getters.ts b/src/server/api/common/getters.ts
index 1fce58b20a..1cd054cab1 100644
--- a/src/server/api/common/getters.ts
+++ b/src/server/api/common/getters.ts
@@ -1,5 +1,6 @@
import * as mongo from 'mongodb';
import Note from "../../../models/note";
+import User, { isRemoteUser, isLocalUser } from "../../../models/user";
/**
* Get valied note for API processing
@@ -16,3 +17,44 @@ export async function getValiedNote(noteId: mongo.ObjectID) {
return note;
}
+
+/**
+ * Get user for API processing
+ */
+export async function getUser(userId: mongo.ObjectID) {
+ const user = await User.findOne({
+ _id: userId
+ });
+
+ if (user == null) {
+ throw 'user not found';
+ }
+
+ return user;
+}
+
+/**
+ * Get remote user for API processing
+ */
+export async function getRemoteUser(userId: mongo.ObjectID) {
+ const user = await getUser(userId);
+
+ if (!isRemoteUser(user)) {
+ throw 'user is not a remote user';
+ }
+
+ return user;
+}
+
+/**
+ * Get local user for API processing
+ */
+export async function getLocalUser(userId: mongo.ObjectID) {
+ const user = await getUser(userId);
+
+ if (!isLocalUser(user)) {
+ throw 'user is not a local user';
+ }
+
+ return user;
+}
diff --git a/src/server/api/endpoints/admin/update-remote-user.ts b/src/server/api/endpoints/admin/update-remote-user.ts
new file mode 100644
index 0000000000..9288ce1fb7
--- /dev/null
+++ b/src/server/api/endpoints/admin/update-remote-user.ts
@@ -0,0 +1,36 @@
+import * as mongo from 'mongodb';
+import $ from 'cafy';
+import ID, { transform } from '../../../../misc/cafy-id';
+import define from '../../define';
+import { getRemoteUser } from '../../common/getters';
+import { updatePerson } from '../../../../remote/activitypub/models/person';
+
+export const meta = {
+ desc: {
+ 'ja-JP': '指定されたリモートユーザーの情報を更新します。',
+ 'en-US': 'Update specified remote user information.'
+ },
+
+ requireCredential: true,
+ requireModerator: true,
+
+ params: {
+ userId: {
+ validator: $.type(ID),
+ transform: transform,
+ desc: {
+ 'ja-JP': '対象のユーザーID',
+ 'en-US': 'The user ID which you want to update'
+ }
+ },
+ }
+};
+
+export default define(meta, (ps) => new Promise((res, rej) => {
+ updatePersonById(ps.userId).then(() => res(), e => rej(e));
+}));
+
+async function updatePersonById(userId: mongo.ObjectID) {
+ const user = await getRemoteUser(userId);
+ await updatePerson(user.uri);
+}