Skip to content

Commit

Permalink
Merge pull request #56 from sakura-tel/sakura-tel/develop
Browse files Browse the repository at this point in the history
2022.07.03-milkey-2.3
  • Loading branch information
atsu1125 authored Dec 30, 2022
2 parents 39b914e + 6285f10 commit c4f8050
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 25 deletions.
5 changes: 5 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,8 @@ showRenoteConfirm: "Show confirmation dialog before renoting"
showUnrenoteConfirm: "Show confirmation dialog before unrenoting"
showVoteConfirm: "Show confirmation dialog before voting"
voteConfirm: "Are you sure that you want to vote?"
deleteAccount: "Delete Account"
deleteAccountConfirm: "Are you sure that you want to delete this account?"

_template:
edit: "Edit Template..."
Expand Down Expand Up @@ -1410,6 +1412,9 @@ _profile:
metadataContent: "Content"
changeAvatar: "Change avatar"
changeBanner: "Change banner"
locationCaution: "It will be published on the Internet. Please do not include detailed addresses except for business use"
birthdayCaution: "It will be published on the Internet. Please handle your personal information with care"
genderCaution: "It will be published on the Internet. Please handle your personal information with care"
_exportOrImport:
allNotes: "All notes"
followingList: "Following"
Expand Down
5 changes: 5 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@ showRenoteConfirm: "リノートする前に確認ダイアログを表示する
showUnrenoteConfirm: "リノート解除する前に確認ダイアログを表示する"
showVoteConfirm: "投票する前に確認ダイアログを表示する"
voteConfirm: "投票しますか?"
deleteAccount: "アカウント削除"
deleteAccountConfirm: "本当にこのアカウントを削除しますか?"

_template:
edit: "定型文を編集…"
Expand Down Expand Up @@ -1520,6 +1522,9 @@ _profile:
metadataContent: "内容"
changeAvatar: "アバター画像を変更"
changeBanner: "バナー画像を変更"
locationCaution: "インターネットに公開されます。ビジネス用途を除き詳細な住所を記載しないでください"
birthdayCaution: "インターネットに公開されます。個人情報は慎重に取り扱ってください"
genderCaution: "インターネットに公開されます。個人情報は慎重に取り扱ってください"

_exportOrImport:
allNotes: "全てのノート"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "groundpolis-milkey",
"version": "2022.07.03-milkey-2.2",
"version": "2022.07.03-milkey-2.3",
"private": true,
"author": "Xeltica <xeltica@gmail.com> , Minemu <minemu398@outlook.jp> , Azuki⪥ <cluikeit_31701@outlook.com> , Remito <remitocat@gmail.com> , atsu1125 <atsuchan@atsuchan.page>",
"contributors": [
Expand Down
19 changes: 9 additions & 10 deletions src/client/components/note-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<MkUserName class="name" v-if="$store.reactiveState.noteNameDisplayMode.value !== 3" :user="note.user"/>
</template>
</MkA>
<span class="is-bot" v-if="note.user.isBot">bot</span>
<span class="is-bot" v-if="note.user.isBot"><Fa :icon="faRobot"/></span>
<span class="is-cat" v-if="note.user.isCat"><Fa :icon="faPaw"/></span>
<GpVerified class="verified" v-if="note.user.isVerified" />
<span class="premium" v-if="note.user.isPremium"><Fa :icon="faCrown"/></span>
<div class="info">
Expand All @@ -29,7 +30,7 @@

<script lang="ts">
import { defineComponent } from 'vue';
import { faHome, faUnlock, faEnvelope, faMobileAlt, faBookmark, faUsers, faHeart, faHeartbeat, faCrown } from '@fortawesome/free-solid-svg-icons';
import { faHome, faUnlock, faEnvelope, faMobileAlt, faBookmark, faUsers, faHeart, faHeartbeat, faCrown, faRobot, faPaw } from '@fortawesome/free-solid-svg-icons';
import { faBookmark as farBookmark } from '@fortawesome/free-regular-svg-icons';
import notePage from '../filters/note';
import { userPage } from '../filters/user';
Expand All @@ -54,7 +55,7 @@ export default defineComponent({
data() {
return {
faHome, faUnlock, faEnvelope, faMobileAlt, faBookmark, farBookmark, faUsers, faHeart, faHeartbeat, faCrown
faHome, faUnlock, faEnvelope, faMobileAlt, faBookmark, farBookmark, faUsers, faHeart, faHeartbeat, faCrown, faRobot, faPaw
};
},
Expand Down Expand Up @@ -100,13 +101,11 @@ export default defineComponent({
}
> .is-bot {
flex-shrink: 0;
align-self: center;
margin: 0 .5em 0 0;
padding: 1px 6px;
font-size: 80%;
border: solid 1px var(--divider);
border-radius: 3px;
margin-right: 0.5em;
}
> .is-cat {
margin-right: 0.5em;
}
> .premium {
Expand Down
21 changes: 21 additions & 0 deletions src/client/pages/instance/user-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<MkButton full v-if="user.host != null" @click="updateRemoteUser"><Fa :icon="faSync"/> {{ $ts.updateRemoteUser }}</MkButton>
<MkButton full @click="resetPassword"><Fa :icon="faKey"/> {{ $ts.resetPassword }}</MkButton>
<MkButton full @click="deleteAllFiles" danger><Fa :icon="faTrashAlt"/> {{ $ts.deleteAllFiles }}</MkButton>
<MkButton v-if="!user.isModerator && !user.isAdmin" full @click="deleteAccount" danger><Fa :icon="faTrashAlt"/> {{ $ts.deleteAccount }}</MkButton>
</div>
</div>
<div class="_section">
Expand Down Expand Up @@ -215,6 +216,26 @@ export default defineComponent({
await this.refreshUser();
},
async deleteAccount() {
const confirm = await os.dialog({
type: 'warning',
showCancelButton: true,
text: this.$ts.deleteAccountConfirm,
});
if (confirm.canceled) return;
const process = async () => {
await os.api('admin/delete-account', { userId: this.user.id });
os.success();
};
await process().catch(e => {
os.dialog({
type: 'error',
text: e.toString()
});
});
await this.refreshUser();
},
acct
}
});
Expand Down
5 changes: 4 additions & 1 deletion src/client/pages/settings/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
<FormInput v-model:value="location">
<span>{{ $ts.location }}</span>
<template #prefix><Fa :icon="faMapMarkerAlt"/></template>
<template #desc>{{ $ts._profile.locationCaution }}</template>
</FormInput>

<FormInput v-model:value="birthday" type="date">
<span>{{ $ts.birthday }}</span>
<template #prefix><Fa :icon="faBirthdayCake"/></template>
<template #desc>{{ $ts._profile.birthdayCaution }}</template>
</FormInput>

<FormSelect v-model:value="gender">
Expand All @@ -36,6 +38,7 @@
<option value="male" v-text="$ts._gender.male" />
<option value="female" v-text="$ts._gender.female" />
<option value="not-applicable" v-text="$ts._gender['not-applicable']" />
<template #caption>{{ $ts._profile.genderCaution }}</template>
</FormSelect>

<FormGroup>
Expand Down Expand Up @@ -100,7 +103,7 @@ export default defineComponent({
FormBase,
FormGroup,
},
emits: ['info'],
data() {
Expand Down
18 changes: 12 additions & 6 deletions src/client/pages/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
<MkUserName class="name" :user="user" :nowrap="true"/>
<div class="bottom">
<span class="username"><MkAcct :user="user" :detail="true" /></span>
<span v-if="user.isAdmin" :title="$ts.isAdmin" style="color: var(--badge);"><Fa :icon="faBookmark"/></span>
<span v-if="!user.isAdmin && user.isModerator" :title="$ts.isModerator" style="color: var(--badge);"><Fa :icon="farBookmark"/></span>
<span v-if="user.isLocked" :title="$ts.isLocked"><Fa :icon="faLock"/></span>
<span v-if="user.isAdmin" :title="$ts.isAdmin" style="color: var(--badge);"><Fa :icon="faWrench"/></span>
<span v-if="!user.isAdmin && user.isModerator" :title="$ts.isModerator" style="color: var(--badge);"><Fa :icon="farBookmark"/></span>
<span v-if="user.isBot" :title="$ts.isBot"><Fa :icon="faRobot"/></span>
<span v-if="user.isCat" :title="$ts.isCat"><Fa :icon="faPaw"/></span>
<span v-if="user.isVerified" :title="$ts.isVerified"><Fa :icon="faStar"/></span>
<span v-if="user.isPremium" :title="$ts.isPremium" style="color: var(--premium);"><Fa :icon="faCrown"/></span>
</div>
</div>
<span class="followed" v-if="$i && $i.id != user.id && user.isFollowed">{{ $ts.followsYou }}</span>
Expand All @@ -37,10 +40,13 @@
<MkUserName :user="user" :nowrap="false" class="name"/>
<div class="bottom">
<span class="username"><MkAcct :user="user" :detail="true" /></span>
<span v-if="user.isAdmin" :title="$ts.isAdmin" style="color: var(--badge);"><Fa :icon="faBookmark"/></span>
<span v-if="!user.isAdmin && user.isModerator" :title="$ts.isModerator" style="color: var(--badge);"><Fa :icon="farBookmark"/></span>
<span v-if="user.isLocked" :title="$ts.isLocked"><Fa :icon="faLock"/></span>
<span v-if="user.isAdmin" :title="$ts.isAdmin" style="color: var(--badge);"><Fa :icon="faWrench"/></span>
<span v-if="!user.isAdmin && user.isModerator" :title="$ts.isModerator" style="color: var(--badge);"><Fa :icon="farBookmark"/></span>
<span v-if="user.isBot" :title="$ts.isBot"><Fa :icon="faRobot"/></span>
<span v-if="user.isCat" :title="$ts.isCat"><Fa :icon="faPaw"/></span>
<span v-if="user.isVerified" :title="$ts.isVerified"><Fa :icon="faStar"/></span>
<span v-if="user.isPremium" :title="$ts.isPremium" style="color: var(--premium);"><Fa :icon="faCrown"/></span>
</div>
</div>
<div class="description">
Expand Down Expand Up @@ -137,7 +143,7 @@

<script lang="ts">
import { defineComponent, defineAsyncComponent, computed } from 'vue';
import { faExclamationTriangle, faEllipsisH, faRobot, faLock, faBookmark, faChartBar, faImage, faBirthdayCake, faMapMarker, faPaperclip, faFileAlt, faPencilAlt, faMars, faVenus, faGenderless } from '@fortawesome/free-solid-svg-icons';
import { faExclamationTriangle, faEllipsisH, faRobot, faLock, faBookmark, faChartBar, faImage, faBirthdayCake, faMapMarker, faPaperclip, faFileAlt, faPencilAlt, faMars, faVenus, faGenderless, faWrench, faPaw, faCrown, faStar } from '@fortawesome/free-solid-svg-icons';
import { faCalendarAlt, faBookmark as farBookmark, faCommentAlt, faSmile } from '@fortawesome/free-regular-svg-icons';
import * as age from 's-age';
import XUserTimeline from './index.timeline.vue';
Expand Down Expand Up @@ -200,7 +206,7 @@ export default defineComponent({
error: null,
parallaxAnimationId: null,
narrow: null,
faExclamationTriangle, faEllipsisH, faRobot, faLock, faBookmark, farBookmark, faChartBar, faImage, faBirthdayCake, faMapMarker, faCalendarAlt, faCommentAlt, faPaperclip, faFileAlt, faSmile,
faExclamationTriangle, faEllipsisH, faRobot, faLock, faBookmark, farBookmark, faChartBar, faImage, faBirthdayCake, faMapMarker, faCalendarAlt, faCommentAlt, faPaperclip, faFileAlt, faSmile, faWrench, faPaw, faCrown, faStar
};
},
Expand Down
16 changes: 9 additions & 7 deletions src/daemons/server-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,27 @@ export default function() {
const fsStats = await fs();

const stats = {
cpu: config.hideServerInfo ? -1 : roundCpu(cpu),
cpu: roundCpu(cpu),
mem: {
used: config.hideServerInfo ? -1 : round(memStats.used),
active: config.hideServerInfo ? -1 : round(memStats.active),
used: round(memStats.used),
active: round(memStats.active),
},
net: {
rx: config.hideServerInfo ? -1 : round(Math.max(0, netStats.rx_sec)),
tx: config.hideServerInfo ? -1 : round(Math.max(0, netStats.tx_sec)),
rx: round(Math.max(0, netStats.rx_sec)),
tx: round(Math.max(0, netStats.tx_sec)),
},
fs: {
r: config.hideServerInfo ? -1 : round(Math.max(0, fsStats.rIO_sec)),
w: config.hideServerInfo ? -1 : round(Math.max(0, fsStats.wIO_sec)),
r: round(Math.max(0, fsStats.rIO_sec)),
w: round(Math.max(0, fsStats.wIO_sec)),
}
};
ev.emit('serverStats', stats);
log.unshift(stats);
if (log.length > 200) log.pop();
}

if (config.hideServerInfo) return;

tick();

setInterval(tick, interval);
Expand Down
66 changes: 66 additions & 0 deletions src/server/api/endpoints/admin/delete-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Users } from '../../../../models';
import $ from 'cafy';
import define from '../../define';
import { doPostSuspend } from '../../../../services/suspend-user';
import { publishUserEvent } from '../../../../services/stream';
import { createDeleteAccountJob } from '../../../../queue';
import { ID } from '../../../../misc/cafy-id';
import { insertModerationLog } from '../../../../services/insert-moderation-log';

export const meta = {
desc: {
'ja-JP': '指定したユーザーを削除します。',
'en-US': 'Dekete a user.'
},

tags: ['admin'],

requireCredential: true as const,
requireModerator: true,

params: {
userId: {
validator: $.type(ID),
desc: {
'ja-JP': '対象のユーザーID',
'en-US': 'The user ID which you want to delete'
}
},
}
};

export default define(meta, async (ps, me) => {
const user = await Users.findOne(ps.userId as string);

if (user == null) {
throw new Error('user not found');
}

if (user.isAdmin) {
throw new Error('cannot suspend admin');
}

if (user.isModerator) {
throw new Error('cannot suspend moderator');
}

if (user.isDeleted) {
return;
}

// 物理削除する前にDelete activityを送信する
await doPostSuspend(user).catch(e => {});

createDeleteAccountJob(user);

await Users.update(user.id, {
isDeleted: true,
});

insertModerationLog(me, 'suspend', {
targetId: user.id,
});

// Terminate streaming
publishUserEvent(user.id, 'terminate', {});
});

0 comments on commit c4f8050

Please sign in to comment.