常にメディアを閲覧注意として投稿するオプションを実装

This commit is contained in:
syuilo 2018-09-14 20:11:01 +09:00
parent f97190ef83
commit a8985df58a
7 changed files with 37 additions and 5 deletions

View File

@ -117,6 +117,7 @@ common:
verified-user: "公式アカウント"
disable-animated-mfm: "投稿内の動きのあるテキストを無効にする"
always-show-nsfw: "常に閲覧注意のメディアを表示する"
always-mark-nsfw: "常にメディアを閲覧注意として投稿"
this-setting-is-this-device-only: "このデバイスのみ"
do-not-use-in-production: 'これは開発ビルドです。本番環境で使用しないでください。'

View File

@ -30,6 +30,7 @@
<h2>%i18n:@other%</h2>
<mk-switch v-model="$store.state.i.isBot" @change="onChangeIsBot" text="%i18n:@is-bot%"/>
<mk-switch v-model="$store.state.i.isCat" @change="onChangeIsCat" text="%i18n:@is-cat%"/>
<mk-switch v-model="alwaysMarkNsfw" text="%i18n:common.always-mark-nsfw%"/>
</section>
</div>
</template>
@ -46,6 +47,12 @@ export default Vue.extend({
birthday: null,
};
},
computed: {
alwaysMarkNsfw: {
get() { return this.$store.state.i.settings.alwaysMarkNsfw; },
set(value) { (this as any).api('i/update', { alwaysMarkNsfw: value }); }
},
},
created() {
this.name = this.$store.state.i.name || '';
this.location = this.$store.state.i.profile.location;

View File

@ -49,6 +49,7 @@
<div>
<ui-switch v-model="isCat" @change="save(false)">%i18n:@is-cat%</ui-switch>
<ui-switch v-model="alwaysMarkNsfw">%i18n:common.always-mark-nsfw%</ui-switch>
</div>
</section>
@ -85,6 +86,13 @@ export default Vue.extend({
};
},
computed: {
alwaysMarkNsfw: {
get() { return this.$store.state.i.settings.alwaysMarkNsfw; },
set(value) { (this as any).api('i/update', { alwaysMarkNsfw: value }); }
},
},
created() {
this.name = this.$store.state.i.name || '';
this.username = this.$store.state.i.username;

View File

@ -102,7 +102,10 @@ export interface ILocalUser extends IUserBase {
twoFactorEnabled: boolean;
twoFactorTempSecret?: string;
clientSettings: any;
settings: any;
settings: {
autoWatch: boolean;
alwaysMarkNsfw?: boolean;
};
hasUnreadNotification: boolean;
hasUnreadMessagingMessage: boolean;
}

View File

@ -31,8 +31,8 @@ export const meta = {
}
}),
isSensitive: $.bool.optional.note({
default: false,
isSensitive: $.bool.optional.nullable.note({
default: null,
desc: {
'ja-JP': 'このメディアが「閲覧注意」(NSFW)かどうか',
'en-US': 'Whether this media is NSFW'

View File

@ -84,6 +84,12 @@ export const meta = {
'ja-JP': '投稿の自動ウォッチをするか否か'
}
}),
alwaysMarkNsfw: $.bool.optional.note({
desc: {
'ja-JP': 'アップロードするメディアをデフォルトで「閲覧注意」として設定するか'
}
}),
}
};
@ -106,6 +112,7 @@ export default async (params: any, user: ILocalUser, app: IApp) => new Promise(a
if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot;
if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat;
if (typeof ps.autoWatch == 'boolean') updates['settings.autoWatch'] = ps.autoWatch;
if (typeof ps.alwaysMarkNsfw == 'boolean') updates['settings.alwaysMarkNsfw'] = ps.alwaysMarkNsfw;
if (ps.avatarId) {
const avatar = await DriveFile.findOne({

View File

@ -153,7 +153,7 @@ export default async function(
isLink: boolean = false,
url: string = null,
uri: string = null,
sensitive = false
sensitive: boolean = null
): Promise<IDriveFile> {
// Calc md5 hash
const calcHash = new Promise<string>((res, rej) => {
@ -329,7 +329,13 @@ export default async function(
properties: properties,
withoutChunks: isLink,
isRemote: isLink,
isSensitive: sensitive
isSensitive: (sensitive !== null && sensitive !== undefined)
? sensitive
: isLocalUser(user)
? user.settings.alwaysMarkNsfw
? true
: false
: false
} as IMetadata;
if (url !== null) {