Merge branch 'develop' of https://github.com/syuilo/misskey into develop

This commit is contained in:
syuilo 2019-01-26 17:54:09 +09:00
commit 2334b41375
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
4 changed files with 94 additions and 2 deletions

View file

@ -1280,6 +1280,8 @@ admin/views/users.vue:
unverify: "公式アカウントを解除する"
unverify-confirm: "公式アカウントを解除しますか?"
unverified: "公式アカウントを解除しました"
update-remote-user: "リモートユーザー情報の更新"
remote-user-updated: "リモートユーザー情報を更新しました"
users:
title: "ユーザー"
sort:

View file

@ -20,6 +20,7 @@
<ui-button @click="suspendUser" :disabled="suspending"><fa :icon="faSnowflake"/> {{ $t('suspend') }}</ui-button>
<ui-button @click="unsuspendUser" :disabled="unsuspending">{{ $t('unsuspend') }}</ui-button>
</ui-horizon-group>
<ui-button v-if="user.host != null" @click="updateRemoteUser"><fa :icon="faSync"/> {{ $t('update-remote-user') }}</ui-button>
<ui-textarea v-if="user" :value="user | json5" readonly tall style="margin-top:16px;"></ui-textarea>
</div>
</div>
@ -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<Boolean> {
const confirm = await this.$root.dialog({
type: 'warning',

View file

@ -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;
}

View file

@ -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);
}