Skip to content

Commit

Permalink
Implement suspend account
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Apr 19, 2018
1 parent 38b9ed3 commit bd207b5
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 4 deletions.
18 changes: 18 additions & 0 deletions cli/suspend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const mongo = require('mongodb');
const User = require('../built/models/user').default;

const args = process.argv.slice(2);

const userId = new mongo.ObjectID(args[0]);

console.log(`Suspending ${userId}...`);

User.update({ _id: userId }, {
$set: {
isSuspended: true
}
}).then(() => {
console.log(`Suspended ${userId}`);
}, e => {
console.error(e);
});
2 changes: 2 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ desktop/views/pages/user/user.friends.vue:
no-users: "No users"

desktop/views/pages/user/user.header.vue:
is-suspended: "This account has been suspended."
is-remote: "This user is a remote user, so the information is not accurate. "
view-remote: "See accurate information"

Expand Down Expand Up @@ -594,6 +595,7 @@ mobile/views/pages/user.vue:
overview: "Overview"
timeline: "Timeline"
media: "Media"
is-suspended: "This account has been suspended."
is-remote: "This user is a remote user, so the information is not accurate. "
view-remote: "See accurate information"

Expand Down
2 changes: 2 additions & 0 deletions locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ desktop/views/pages/user/user.friends.vue:
no-users: "Pas d'utilisateurs"

desktop/views/pages/user/user.header.vue:
is-suspended: "This account has been suspended."
is-remote: "Cet utilisateur n'est pas un utilisateur de Misskey. Certaines informations peuvent être erronées "
view-remote: "Voir les informations détaillées"

Expand Down Expand Up @@ -594,6 +595,7 @@ mobile/views/pages/user.vue:
overview: "Aperçu"
timeline: "Fil d'actualité"
media: "Media"
is-suspended: "This account has been suspended."
is-remote: "Cet utilisateur n'est pas un utilisateur de Misskey. Certaines informations peuvent être erronées "
view-remote: "Voir les informations détaillées"

Expand Down
2 changes: 2 additions & 0 deletions locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ desktop/views/pages/user/user.friends.vue:
no-users: "よく話すユーザーはいません"

desktop/views/pages/user/user.header.vue:
is-suspended: "このユーザーは凍結されています。"
is-remote: "このユーザーはリモートユーザーです。"
view-remote: "正確な情報を見る"

Expand Down Expand Up @@ -594,6 +595,7 @@ mobile/views/pages/user.vue:
overview: "概要"
timeline: "タイムライン"
media: "メディア"
is-suspended: "このユーザーは凍結されています。"
is-remote: "このユーザーはリモートユーザーです。"
view-remote: "正確な情報を見る"

Expand Down
12 changes: 10 additions & 2 deletions src/client/app/desktop/views/pages/user/user.header.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="header" :data-is-dark-background="user.bannerUrl != null">
<div class="is-suspended" v-if="user.isSuspended"><p>%fa:exclamation-triangle% %i18n:@is-suspended%</p></div>
<div class="is-remote" v-if="user.host != null"><p>%fa:exclamation-triangle% %i18n:@is-remote%<a :href="user.url || user.uri" target="_blank">%i18n:@view-remote%</a></p></div>
<div class="banner-container" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl}?thumbnail&size=2048)` : ''">
<div class="banner" ref="banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl}?thumbnail&size=2048)` : ''" @click="onBannerClick"></div>
Expand Down Expand Up @@ -73,10 +74,17 @@ export default Vue.extend({
background #f7f7f7
box-shadow 0 1px 1px rgba(0, 0, 0, 0.075)
> .is-suspended
> .is-remote
padding 16px
color #573c08
background #fff0db
&.is-suspended
color #570808
background #ffdbdb
&.is-remote
color #573c08
background #fff0db
> p
margin 0 auto
Expand Down
12 changes: 10 additions & 2 deletions src/client/app/mobile/views/pages/user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<mk-ui>
<span slot="header" v-if="!fetching">%fa:user% {{ user | userName }}</span>
<main v-if="!fetching">
<div class="is-suspended" v-if="user.isSuspended"><p>%fa:exclamation-triangle% %i18n:@is-suspended%</p></div>
<div class="is-remote" v-if="user.host != null"><p>%fa:exclamation-triangle% %i18n:@is-remote%<a :href="user.url || user.uri" target="_blank">%i18n:@view-remote%</a></p></div>
<header>
<div class="banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl}?thumbnail&size=1024)` : ''"></div>
Expand Down Expand Up @@ -110,10 +111,17 @@ export default Vue.extend({
@import '~const.styl'
main
> .is-suspended
> .is-remote
padding 16px
color #573c08
background #fff0db
&.is-suspended
color #570808
background #ffdbdb
&.is-remote
color #573c08
background #fff0db
> p
margin 0 auto
Expand Down
5 changes: 5 additions & 0 deletions src/remote/activitypub/models/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const log = debug('misskey:activitypub');
* Imageを作成します。
*/
export async function createImage(actor: IRemoteUser, value): Promise<IDriveFile> {
// 投稿者が凍結されていたらスキップ
if (actor.isSuspended) {
return null;
}

const image = await new Resolver().resolve(value);

if (image.url == null) {
Expand Down
5 changes: 5 additions & 0 deletions src/remote/activitypub/models/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
// 投稿者をフェッチ
const actor = await resolvePerson(note.attributedTo) as IRemoteUser;

// 投稿者が凍結されていたらスキップ
if (actor.isSuspended) {
return null;
}

//#region Visibility
let visibility = 'public';
if (!note.to.includes('https://www.w3.org/ns/activitystreams#Public')) visibility = 'unlisted';
Expand Down

0 comments on commit bd207b5

Please sign in to comment.