mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-12-22 08:20:10 +00:00
管理画面からリモートユーザー情報を更新できるように (#3992)
This commit is contained in:
parent
a0f8c7e94e
commit
0854f2e180
4 changed files with 94 additions and 2 deletions
|
@ -1280,6 +1280,8 @@ admin/views/users.vue:
|
|||
unverify: "公式アカウントを解除する"
|
||||
unverify-confirm: "公式アカウントを解除しますか?"
|
||||
unverified: "公式アカウントを解除しました"
|
||||
update-remote-user: "リモートユーザー情報の更新"
|
||||
remote-user-updated: "リモートユーザー情報を更新しました"
|
||||
users:
|
||||
title: "ユーザー"
|
||||
sort:
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
36
src/server/api/endpoints/admin/update-remote-user.ts
Normal file
36
src/server/api/endpoints/admin/update-remote-user.ts
Normal 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);
|
||||
}
|
Loading…
Reference in a new issue