Merge branch 'develop' into vue3

This commit is contained in:
syuilo 2020-08-25 08:54:57 +09:00
commit 7326f45ffd
24 changed files with 390 additions and 145 deletions

View File

@ -264,6 +264,7 @@ rename: "Renombrar"
avatar: "Avatar"
banner: "Banner"
nsfw: "Marcado como sensible"
whenServerDisconnected: "Cuando se pierda la conexión con el servidor"
disconnectedFromServer: "Desconectado del servidor"
reload: "Recargar"
doNothing: "No hacer nada"
@ -563,8 +564,22 @@ overview: "Resumen"
logs: "Registros"
delayed: "atrasado"
database: "Base de datos"
channel: "Canal"
create: "Crear"
_serverDisconnectedBehavior:
reload: "Recargar automáticamente"
dialog: "Mostrar diálogo de advertencia"
quiet: "Advertencia discreta"
_channel:
create: "Crear canal"
edit: "Editar canal"
setBanner: "Elegir banner"
removeBanner: "Borrar banner"
featured: "Tendencias"
owned: "Dueño"
following: "Siguiendo"
usersCount: "{n} participantes"
notesCount: "{n} notas"
_sidebar:
full: "Completo"
icon: "Avatar"
@ -656,6 +671,7 @@ _sfx:
chat: "Chat"
chatBg: "Chat (Fondo)"
antenna: "Antena receptora"
channel: "Notificaciones del canal"
_ago:
unknown: "Desconocido"
future: "Futuro"
@ -731,6 +747,8 @@ _permissions:
"write:page-likes": "Administrar páginas que te gustan"
"read:user-groups": "Ver grupos de usuarios"
"write:user-groups": "Administrar grupos de usuarios"
"read:channels": "Ver canal"
"write:channels": "Modificar canal"
_auth:
shareAccess: "¿Desea permitir el acceso a la cuenta \"{name}\"?"
shareAccessAsk: "¿Está seguro de que desea autorizar esta aplicación para acceder a su cuenta?"
@ -805,6 +823,7 @@ _visibility:
_postForm:
replyPlaceholder: "Responder a esta nota"
quotePlaceholder: "Citar esta nota"
channelPlaceholder: "Postear en el canal"
_placeholders:
a: "¿Qué haces?"
b: "¿Te pasó algo?"

View File

@ -566,6 +566,10 @@ delayed: "遅延"
database: "データベース"
channel: "チャンネル"
create: "作成"
notificationSetting: "通知設定"
notificationSettingDesc: "表示する通知の種別を選択してください。"
useGlobalSetting: "グローバル設定を使う"
useGlobalSettingDesc: "オンにすると、アカウントの通知設定が使用されます。オフにすると、個別に設定できるようになります。"
_serverDisconnectedBehavior:
reload: "自動でリロード"
@ -1285,8 +1289,11 @@ _notification:
renote: "Renote"
quote: "引用"
reaction: "リアクション"
pollVote: "投票"
receiveFollowRequest: "フォローリクエスト"
pollVote: "アンケートに投票された"
receiveFollowRequest: "フォロー申請を受け取った"
followRequestAccepted: "フォローが受理された"
groupInvited: "グループに招待された"
app: "連携アプリからの通知"
_deck:
alwaysShowMainColumn: "常にメインカラムを表示"

View File

@ -551,13 +551,21 @@ makeActive: "활성화"
copy: "복사"
logs: "로그"
database: "데이터베이스"
channel: "채널"
_channel:
create: "채널 생성"
setBanner: "배너 설정"
removeBanner: "배너 삭제"
featured: "트렌드"
following: "팔로잉"
usersCount: "{n}명 참여 중"
notesCount: "{n}노트"
_sidebar:
icon: "아바타"
hide: "숨기기"
_wordMute:
muteWords: "뮤트할 단어"
mutedNotes: "뮤트된 노트"
_theme:
explore: "테마 찾아보기"
install: "테마 설치"
@ -578,6 +586,7 @@ _theme:
func: "함수"
funcKind: "함수 종류"
argument: "매개변수"
importInfo: "여기에 테마 코드를 붙여 넣어 에디터로 불러올 수 있습니다."
keys:
link: "링크"
hashtag: "해시태그"

View File

@ -359,7 +359,7 @@ moderator: "版主"
nUsersMentioned: "{n} 被提到"
securityKey: "安全密钥"
securityKeyName: "密钥名称"
registerSecurityKey: "注册安全密钥"
registerSecurityKey: "注册硬件安全密钥"
lastUsed: "最后使用:"
unregister: "删除账户"
passwordLessLogin: "无密码登录"
@ -455,13 +455,13 @@ showFeaturedNotesInTimeline: "在时间线上显示热门推荐"
objectStorage: "对象存储"
useObjectStorage: "使用对象存储"
objectStorageBaseUrl: "基本网址"
objectStorageBaseUrlDesc: "供参考的URL。如果使用CDN或Proxy则其URL为S3\"https://<bucket>.s3.amazonaws.com\"、GCS等\"https://storage-googleapis.proxy.ustclug.org/<bucket>\"。"
objectStorageBaseUrlDesc: "URL前缀用于构造URL到对象媒体的引用如果您使用的是CDN或反向代理请指定其URL否则请根据您使用的服务指定可公开访问的地址。例如“https://<bucket>.s3.amazonaws.com”用于AWS S3“https://storage.googleapis.com/<bucket>”用于GCS"
objectStorageBucket: "存储桶"
objectStorageBucketDesc: "请指定使用的对象存储服务的存储桶名称。"
objectStoragePrefix: "前缀"
objectStoragePrefixDesc: "文件将存储在此前缀的目录下。"
objectStorageEndpoint: "端点"
objectStorageEndpointDesc: "S3默认情况下为空否则请为每个服务指定端点。 指定为“<host>”或“<host>:<port>”。"
objectStorageEndpointDesc: "如果你希望使用AWS S3请留空。否则请根据你使用的服务来进行设置指定端点形式为“<host>”或“<host>:<port>”。"
objectStorageRegion: "可用区"
objectStorageRegionDesc: "指定一个可用区例如“xx-east-1”。 如果您的对象存储服务没有可用区概念请将其留空或填写“us-east-1”。"
objectStorageUseSSL: "使用SSL"
@ -568,6 +568,8 @@ channel: "频道"
create: "创建"
_serverDisconnectedBehavior:
reload: "自动重载"
dialog: "对话框警告"
quiet: "安静警告"
_channel:
create: "创建频道"
edit: "编辑频道"
@ -650,7 +652,7 @@ _theme:
cwFg: "CW 按钮文本"
cwHoverBg: "CW 按钮背景(悬停)"
toastBg: "吐司提示背景"
toastFg: "司提示文本"
toastFg: "司提示文本"
buttonBg: "按钮背景"
buttonHoverBg: "按钮背景(悬停)"
inputBorder: "输入框边框"
@ -706,7 +708,7 @@ _tutorial:
step6_1: "现在,您将可以在时间线上看到其他用户的帖子。"
step6_2: "您还可以在其他人的帖子上进行「回应」,以快速做出简单回复。"
step6_3: "在他人的贴子上按下「+」图标,即可选择想要的表情来进行「回应」。"
step7_1: "对Misskey基本操作的简单介绍到此结束了。 辛苦了!"
step7_1: "对Misskey基本操作的简单介绍到此结束了。 辛苦了!"
step7_2: "如果你想了解更多有关Misskey的信息请参见{help}。"
step7_3: "接下来享受Misskey带来的乐趣吧🚀"
_2fa:
@ -717,7 +719,7 @@ _2fa:
step2: "然后,扫描屏幕上显示的二维码。"
step3: "输入您的应用提供的动态口令以完成设置。"
step4: "从现在开始,任何登录操作都将要求您提供动态口令。"
securityKeyInfo: "您可以设置使用支持FIDO2的硬件安全密钥、指纹或设备上的PIN来保护您的登录过程。"
securityKeyInfo: "您可以设置使用支持FIDO2的硬件安全密钥、设备上的指纹或PIN来保护您的登录过程。"
_permissions:
"read:account": "查看账户信息"
"write:account": "更改帐户信息"

View File

@ -0,0 +1,16 @@
import {MigrationInterface, QueryRunner} from "typeorm";
export class IncludingNotificationTypes1597236229720 implements MigrationInterface {
name = 'IncludingNotificationTypes1597236229720'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TYPE "user_profile_includingnotificationtypes_enum" AS ENUM('follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app')`);
await queryRunner.query(`ALTER TABLE "user_profile" ADD "includingNotificationTypes" "user_profile_includingnotificationtypes_enum" array`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "includingNotificationTypes"`);
await queryRunner.query(`DROP TYPE "user_profile_includingnotificationtypes_enum"`);
}
}

View File

@ -1,7 +1,7 @@
{
"name": "misskey",
"author": "syuilo <syuilotan@yahoo.co.jp>",
"version": "12.47.0",
"version": "12.47.1",
"codename": "indigo",
"repository": {
"type": "git",
@ -114,7 +114,7 @@
"aws-sdk": "2.724.0",
"bcryptjs": "2.4.3",
"blurhash": "1.1.3",
"bull": "3.16.0",
"bull": "3.18.0",
"cafy": "15.2.1",
"cbor": "5.1.0",
"chalk": "4.1.0",
@ -159,7 +159,7 @@
"is-root": "2.1.0",
"is-svg": "4.2.1",
"js-yaml": "3.14.0",
"jsdom": "16.3.0",
"jsdom": "16.4.0",
"json5": "2.1.3",
"json5-loader": "4.0.0",
"jsonld": "3.1.1",
@ -190,7 +190,8 @@
"os-utils": "0.0.14",
"parse5": "6.0.1",
"parsimmon": "1.15.0",
"pg": "8.3.0",
"pg": "8.3.2",
"portal-vue": "2.1.7",
"portscanner": "2.2.0",
"postcss-loader": "3.0.0",
"prismjs": "1.21.0",
@ -199,7 +200,7 @@
"promise-sequential": "1.1.1",
"pug": "2.0.4",
"punycode": "2.1.1",
"pureimage": "0.2.4",
"pureimage": "0.2.5",
"qrcode": "1.4.4",
"random-seed": "0.3.0",
"ratelimiter": "3.4.1",
@ -225,18 +226,18 @@
"style-loader": "1.2.1",
"summaly": "2.4.0",
"syslog-pro": "1.0.0",
"systeminformation": "4.26.10",
"systeminformation": "4.26.12",
"syuilo-password-strength": "0.0.1",
"textarea-caret": "3.1.0",
"three": "0.117.1",
"tinycolor2": "1.4.1",
"tmp": "0.2.1",
"ts-loader": "8.0.2",
"ts-node": "8.10.2",
"ts-node": "9.0.0",
"tslint": "6.1.3",
"tslint-sonarts": "1.9.0",
"typeorm": "0.2.25",
"typescript": "3.9.7",
"typescript": "4.0.2",
"ulid": "2.3.0",
"url-loader": "4.1.0",
"uuid": "8.3.0",
@ -252,14 +253,14 @@
"vue-marquee-text-component": "1.1.1",
"vue-meta": "2.4.0",
"vue-prism-component": "1.2.0",
"vue-prism-editor": "0.6.1",
"vue-prism-editor": "1.2.2",
"vue-router": "4.0.0-beta.7",
"vue-style-loader": "4.1.2",
"vue-svg-inline-loader-corejs3": "1.5.0",
"vue-template-compiler": "2.6.11",
"vuedraggable": "2.24.0",
"vuedraggable": "2.24.1",
"vuex": "4.0.0-beta.4",
"vuex-persistedstate": "3.0.1",
"vuex-persistedstate": "3.1.0",
"web-push": "3.4.4",
"webpack": "5.0.0-beta.28",
"webpack-cli": "3.3.12",

View File

@ -2,7 +2,7 @@
<x-column :column="column" :is-stacked="isStacked" :menu="menu">
<template #header><fa :icon="faBell" style="margin-right: 8px;"/>{{ column.name }}</template>
<x-notifications/>
<x-notifications :include-types="column.includingTypes"/>
</x-column>
</template>
@ -38,28 +38,14 @@ export default defineComponent({
},
created() {
if (this.column.notificationType == null) {
this.column.notificationType = 'all';
this.$store.commit('deviceUser/updateDeckColumn', this.column);
}
this.menu = [{
icon: faCog,
text: this.$t('notificationType'),
action: () => {
this.$root.dialog({
title: this.$t('notificationType'),
type: null,
select: {
items: ['all', 'follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'receiveFollowRequest'].map(x => ({
value: x, text: this.$t(`_notification._types.${x}`)
}))
default: this.column.notificationType,
},
showCancelButton: true
}).then(({ canceled, result: type }) => {
if (canceled) return;
this.column.notificationType = type;
text: this.$t('notificationSetting'),
action: async () => {
this.$root.new(await import('../notification-setting-window.vue').then(m => m.default), {
includingTypes: this.column.includingTypes,
}).$on('ok', async ({ includingTypes }) => {
this.$set(this.column, 'includingTypes', includingTypes);
this.$store.commit('deviceUser/updateDeckColumn', this.column);
});
}

View File

@ -0,0 +1,98 @@
<template>
<x-window ref="window" :width="400" :height="450" :no-padding="true" @closed="() => { $emit('closed'); destroyDom(); }" :with-ok-button="true" :ok-button-disabled="false" @ok="ok()">
<template #header>{{ $t('notificationSetting') }}</template>
<div class="vv94n3oa">
<div v-if="showGlobalToggle">
<mk-switch v-model="useGlobalSetting">
{{ $t('useGlobalSetting') }}
<template #desc>{{ $t('useGlobalSettingDesc') }}</template>
</mk-switch>
</div>
<div v-if="!useGlobalSetting">
<mk-info>{{ $t('notificationSettingDesc') }}</mk-info>
<mk-button inline @click="disableAll">{{ $t('disableAll') }}</mk-button>
<mk-button inline @click="enableAll">{{ $t('enableAll') }}</mk-button>
<mk-switch v-for="type in notificationTypes" :key="type" v-model="typesMap[type]">{{ $t(`_notification._types.${type}`) }}</mk-switch>
</div>
</div>
</x-window>
</template>
<script lang="ts">
import Vue, { PropType } from 'vue';
import XWindow from './window.vue';
import MkSwitch from './ui/switch.vue';
import MkInfo from './ui/info.vue';
import MkButton from './ui/button.vue';
import { notificationTypes } from '../../types';
export default Vue.extend({
components: {
XWindow,
MkSwitch,
MkInfo,
MkButton
},
props: {
includingTypes: {
// TODO: 調
type: Array as PropType<typeof notificationTypes[number][]>,
required: false,
default: null,
},
showGlobalToggle: {
type: Boolean,
required: false,
default: true,
}
},
data() {
return {
typesMap: {} as Record<typeof notificationTypes[number], boolean>,
useGlobalSetting: false,
notificationTypes,
};
},
created() {
this.useGlobalSetting = this.includingTypes === null && this.showGlobalToggle;
for (const type of this.notificationTypes) {
Vue.set(this.typesMap, type, this.includingTypes === null || this.includingTypes.includes(type));
}
},
methods: {
ok() {
const includingTypes = this.useGlobalSetting ? null : (Object.keys(this.typesMap) as typeof notificationTypes[number][])
.filter(type => this.typesMap[type]);
this.$emit('ok', { includingTypes });
this.$refs.window.close();
},
disableAll() {
for (const type in this.typesMap) {
this.typesMap[type as typeof notificationTypes[number]] = false;
}
},
enableAll() {
for (const type in this.typesMap) {
this.typesMap[type as typeof notificationTypes[number]] = true;
}
}
}
});
</script>
<style lang="scss" scoped>
.vv94n3oa {
> div {
border-top: solid 1px var(--divider);
padding: 24px;
}
}
</style>

View File

@ -17,11 +17,12 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { defineComponent, PropType } from 'vue';
import paging from '../scripts/paging';
import XNotification from './notification.vue';
import XList from './date-separated-list.vue';
import XNote from './note.vue';
import { notificationTypes } from '../../types';
export default defineComponent({
components: {
@ -35,9 +36,10 @@ export default defineComponent({
],
props: {
type: {
type: String,
required: false
includeTypes: {
type: Array as PropType<typeof notificationTypes[number][]>,
required: false,
default: null,
},
},
@ -48,15 +50,26 @@ export default defineComponent({
endpoint: 'i/notifications',
limit: 10,
params: () => ({
includeTypes: this.type ? [this.type] : undefined
includeTypes: this.allIncludeTypes || undefined,
})
},
};
},
computed: {
allIncludeTypes() {
return this.includeTypes ?? this.$store.state.i.includingNotificationTypes;
}
},
watch: {
type() {
includeTypes() {
this.reload();
},
'$store.state.i.includingNotificationTypes'() {
if (this.includeTypes === null) {
this.reload();
}
}
},
@ -71,16 +84,20 @@ export default defineComponent({
methods: {
onNotification(notification) {
if (document.visibilityState === 'visible') {
//
const isMuted = !!this.allIncludeTypes && !this.allIncludeTypes.includes(notification.type);
if (isMuted || document.visibilityState === 'visible') {
this.$root.stream.send('readNotification', {
id: notification.id
});
}
this.prepend({
...notification,
isRead: document.visibilityState === 'visible'
});
if (!isMuted) {
this.prepend({
...notification,
isRead: document.visibilityState === 'visible'
});
}
},
noteUpdated(oldValue, newValue) {

View File

@ -13,7 +13,11 @@
>
<slot></slot>
</select>
<div class="suffix"><slot name="suffix"></slot></div>
<div class="suffix">
<slot name="suffix">
<fa :icon="faChevronDown"/>
</slot>
</div>
</div>
<div class="text"><slot name="text"></slot></div>
</div>
@ -21,6 +25,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { faChevronDown } from '@fortawesome/free-solid-svg-icons';
export default defineComponent({
props: {
@ -43,7 +48,8 @@ export default defineComponent({
},
data() {
return {
focused: false
focused: false,
faChevronDown,
};
},
computed: {
@ -157,6 +163,8 @@ export default defineComponent({
border-radius: 0;
outline: none;
box-shadow: none;
appearance: none;
-webkit-appearance: none;
color: var(--fg);
option,
@ -172,7 +180,7 @@ export default defineComponent({
justify-self: center;
font-size: 1em;
line-height: 32px;
color: rgba(#000, 0.54);
color: var(--inputLabel);
pointer-events: none;
&:empty {

View File

@ -155,6 +155,11 @@ export default defineComponent({
},
async onNotification(notification) {
const t = this.$store.state.i.includingNotificationTypes;
if (!!t && !t.includes(notification.type)) {
return;
}
if (document.visibilityState === 'visible') {
this.$root.stream.send('readNotification', {
id: notification.id
@ -164,7 +169,6 @@ export default defineComponent({
notification
});
}
this.$root.sound('notification');
},

View File

@ -325,6 +325,10 @@ export default defineComponent({
},
async onNotification(notification) {
const t = this.$store.state.i.includingNotificationTypes;
if (!!t && !t.includes(notification.type)) {
return;
}
if (document.visibilityState === 'visible') {
this.$root.stream.send('readNotification', {
id: notification.id

View File

@ -21,6 +21,9 @@
<mk-button @click="readAllUnreadNotes">{{ $t('markAsReadAllUnreadNotes') }}</mk-button>
<mk-button @click="readAllMessagingMessages">{{ $t('markAsReadAllTalkMessages') }}</mk-button>
</div>
<div class="_content">
<mk-button @click="configure">{{ $t('notificationSetting') }}</mk-button>
</div>
</section>
<x-import-export class="_vMargin"/>
@ -108,6 +111,24 @@ export default defineComponent({
readAllNotifications() {
this.$root.api('notifications/mark-all-as-read');
},
async configure() {
this.$root.new(await import('../../components/notification-setting-window.vue').then(m => m.default), {
includingTypes: this.$store.state.i.includingNotificationTypes,
showGlobalToggle: false,
}).$on('ok', async ({ includingTypes: value }: any) => {
await this.$root.api('i/update', {
includingNotificationTypes: value,
}).then(i => {
this.$store.state.i.includingNotificationTypes = i.includingNotificationTypes;
}).catch(err => {
this.$root.dialog({
type: 'error',
text: err.message
});
});
});
}
}
});
</script>

View File

@ -76,7 +76,7 @@
<mk-container :body-togglable="true" :expanded="true">
<template #header><fa :icon="faCode"/> {{ $t('script') }}</template>
<div>
<prism-editor v-model="script" :line-numbers="false" language="js"/>
<prism-editor class="_code" v-model="script" :highlight="highlighter" :line-numbers="false"/>
</div>
</mk-container>
</div>
@ -85,9 +85,13 @@
<script lang="ts">
import { defineComponent } from 'vue';
import * as XDraggable from 'vuedraggable';
import "prismjs";
import 'prismjs';
import { highlight, languages } from 'prismjs/components/prism-core';
import 'prismjs/components/prism-clike';
import 'prismjs/components/prism-javascript';
import 'prismjs/themes/prism-okaidia.css';
import PrismEditor from 'vue-prism-editor';
import { PrismEditor } from 'vue-prism-editor';
import 'vue-prism-editor/dist/prismeditor.min.css';
import { faICursor, faPlus, faMagic, faCog, faCode, faExternalLinkSquareAlt } from '@fortawesome/free-solid-svg-icons';
import { faSave, faStickyNote, faTrashAlt } from '@fortawesome/free-regular-svg-icons';
import { v4 as uuid } from 'uuid';
@ -416,7 +420,11 @@ export default defineComponent({
removeEyeCatchingImage() {
this.eyeCatchingImageId = null;
}
},
highlighter(code) {
return highlight(code, languages.js, 'javascript');
},
}
});
</script>

View File

@ -3,7 +3,7 @@
<teleport to="#_teleport_header"><fa :icon="faTerminal"/>{{ $t('scratchpad') }}</teleport>
<div class="_panel">
<prism-editor v-model="code" :line-numbers="false" language="js"/>
<prism-editor class="_code" v-model="code" :highlight="highlighter" :line-numbers="false"/>
<mk-button style="position: absolute; top: 8px; right: 8px;" @click="run()" primary><fa :icon="faPlay"/></mk-button>
</div>
@ -23,9 +23,13 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { faTerminal, faPlay } from '@fortawesome/free-solid-svg-icons';
import "prismjs";
import 'prismjs';
import { highlight, languages } from 'prismjs/components/prism-core';
import 'prismjs/components/prism-clike';
import 'prismjs/components/prism-javascript';
import 'prismjs/themes/prism-okaidia.css';
import PrismEditor from 'vue-prism-editor';
import { PrismEditor } from 'vue-prism-editor';
import 'vue-prism-editor/dist/prismeditor.min.css';
import { AiScript, parse, utils, values } from '@syuilo/aiscript';
import MkContainer from '../components/ui/container.vue';
import MkButton from '../components/ui/button.vue';
@ -118,7 +122,11 @@ export default defineComponent({
text: e
});
}
}
},
highlighter(code) {
return highlight(code, languages.js, 'javascript');
},
}
});
</script>

View File

@ -21,6 +21,11 @@ export type FormItem = {
default: string | null;
hidden?: boolean;
enum: string[];
} | {
label?: string;
type: 'array';
default: unknown[] | null;
hidden?: boolean;
};
export type Form = Record<string, FormItem>;

View File

@ -448,6 +448,19 @@ hr {
opacity: 0.7;
}
._code {
background: #2d2d2d;
color: #ccc;
font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
font-size: 14px;
line-height: 1.5;
padding: 5px;
}
.prism-editor__textarea:focus {
outline: none;
}
.zoom-enter-active, .zoom-leave-active {
transition: opacity 0.5s, transform 0.5s !important;
}

View File

@ -1,16 +1,17 @@
<template>
<mk-container :style="`height: ${props.height}px;`" :show-header="props.showHeader" :scrollable="true">
<template #header><fa :icon="faBell"/>{{ $t('notifications') }}</template>
<template #func><button @click="configure()" class="_button"><fa :icon="faCog"/></button></template>
<div>
<x-notifications/>
<x-notifications :include-types="props.includingTypes"/>
</div>
</mk-container>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { faBell } from '@fortawesome/free-solid-svg-icons';
import { faBell, faCog } from '@fortawesome/free-solid-svg-icons';
import MkContainer from '../components/ui/container.vue';
import XNotifications from '../components/notifications.vue';
import define from './define';
@ -26,6 +27,11 @@ const widget = define({
type: 'number',
default: 300,
},
includingTypes: {
type: 'array',
hidden: true,
default: null,
},
})
});
@ -38,8 +44,19 @@ export default defineComponent({
data() {
return {
faBell
faBell, faCog
};
},
methods: {
async configure() {
this.$root.new(await import('../components/notification-setting-window.vue').then(m => m.default), {
includingTypes: this.props.includingTypes,
}).$on('ok', async ({ includingTypes }) => {
this.props.includingTypes = includingTypes;
this.save();
});
}
}
});
</script>

View File

@ -2,6 +2,7 @@ import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'type
import { id } from '../id';
import { User } from './user';
import { Page } from './page';
import { notificationTypes } from '../../types';
@Entity()
export class UserProfile {
@ -158,6 +159,13 @@ export class UserProfile {
})
public mutedWords: string[][];
@Column('enum', {
enum: notificationTypes,
array: true,
nullable: true,
})
public includingNotificationTypes: typeof notificationTypes[number][] | null;
//#region Denormalized fields
@Index()
@Column('varchar', {

View File

@ -248,6 +248,7 @@ export class UserRepository extends Repository<User> {
hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id),
integrations: profile!.integrations,
mutedWords: profile!.mutedWords,
includingNotificationTypes: profile?.includingNotificationTypes,
} : {}),
...(opts.includeSecrets ? {

View File

@ -44,12 +44,10 @@ export const meta = {
includeTypes: {
validator: $.optional.arr($.str.or(notificationTypes as unknown as string[])),
default: [] as string[]
},
excludeTypes: {
validator: $.optional.arr($.str.or(notificationTypes as unknown as string[])),
default: [] as string[]
}
},
@ -65,6 +63,14 @@ export const meta = {
};
export default define(meta, async (ps, user) => {
// includeTypes が空の場合はクエリしない
if (ps.includeTypes && ps.includeTypes.length === 0) {
return [];
}
// excludeTypes に全指定されている場合はクエリしない
if (notificationTypes.every(type => ps.excludeTypes?.includes(type))) {
return [];
}
const followingQuery = Followings.createQueryBuilder('following')
.select('following.followeeId')
.where('following.followerId = :followerId', { followerId: user.id });
@ -91,9 +97,9 @@ export default define(meta, async (ps, user) => {
query.setParameters(followingQuery.getParameters());
}
if (ps.includeTypes!.length > 0) {
if (ps.includeTypes?.length > 0) {
query.andWhere(`notification.type IN (:...includeTypes)`, { includeTypes: ps.includeTypes });
} else if (ps.excludeTypes!.length > 0) {
} else if (ps.excludeTypes?.length > 0) {
query.andWhere(`notification.type NOT IN (:...excludeTypes)`, { excludeTypes: ps.excludeTypes });
}

View File

@ -14,6 +14,7 @@ import { Users, DriveFiles, UserProfiles, Pages } from '../../../../models';
import { User } from '../../../../models/entities/user';
import { UserProfile } from '../../../../models/entities/user-profile';
import { ensure } from '../../../../prelude/ensure';
import { notificationTypes } from '../../../../types';
export const meta = {
desc: {
@ -147,6 +148,10 @@ export const meta = {
mutedWords: {
validator: $.optional.arr($.arr($.str))
},
includingNotificationTypes: {
validator: $.optional.arr($.str.or(notificationTypes as unknown as string[]))
},
},
errors: {
@ -201,6 +206,7 @@ export default define(meta, async (ps, user, token) => {
profileUpdates.mutedWords = ps.mutedWords;
profileUpdates.enableWordMute = ps.mutedWords.length > 0;
}
if (ps.includingNotificationTypes !== undefined) profileUpdates.includingNotificationTypes = ps.includingNotificationTypes as typeof notificationTypes[number][];
if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked;
if (typeof ps.isBot === 'boolean') updates.isBot = ps.isBot;
if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot;

View File

@ -1,6 +1,6 @@
import { publishMainStream } from './stream';
import pushSw from './push-notification';
import { Notifications, Mutings } from '../models';
import { Notifications, Mutings, UserProfiles } from '../models';
import { genId } from '../misc/gen-id';
import { User } from '../models/entities/user';
import { Notification } from '../models/entities/notification';
@ -14,13 +14,18 @@ export async function createNotification(
return null;
}
const profile = await UserProfiles.findOne({ userId: notifieeId });
const isMuted = !profile?.includingNotificationTypes?.includes(type);
// Create notification
const notification = await Notifications.save({
id: genId(),
createdAt: new Date(),
notifieeId: notifieeId,
type: type,
isRead: false,
// 相手がこの通知をミュートしているようなら、既読を予めつけておく
isRead: isMuted,
...data
} as Partial<Notification>);

122
yarn.lock
View File

@ -1914,21 +1914,21 @@ builtin-modules@^1.1.1:
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=
bull@3.16.0:
version "3.16.0"
resolved "https://registry.yarnpkg.com/bull/-/bull-3.16.0.tgz#adabb8404ebecedfbe4f3b9b2163e249de1915ff"
integrity sha512-5RAeKPJwhzuk5y4TL5ys+mX1p1r8TOKUF537c2VFVqg0Z+Y2zL1gXfgk0OAlIhD+9E/q3BgRvN96AxUz6nfBDA==
bull@3.18.0:
version "3.18.0"
resolved "https://registry.yarnpkg.com/bull/-/bull-3.18.0.tgz#7d7730c8ab0975ea9ee4e74f6f85bd731c3526cb"
integrity sha512-nE/BKlg1dnJ/AcOy5D1nzthcmpAKqpUVXzQ43mJfnVC8ZM7mi4ZzP3spN7745UuikzmGGsbTe9px2TbEKhR+DQ==
dependencies:
cron-parser "^2.13.0"
debuglog "^1.0.0"
get-port "^5.1.1"
ioredis "^4.14.1"
lodash "^4.17.15"
lodash "^4.17.19"
p-timeout "^3.2.0"
promise.prototype.finally "^3.1.2"
semver "^6.3.0"
semver "^7.3.2"
util.promisify "^1.0.1"
uuid "^8.2.0"
uuid "^8.3.0"
busboy@^0.2.11:
version "0.2.14"
@ -2507,16 +2507,6 @@ component-emitter@^1.2.1:
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==
component-props@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/component-props/-/component-props-1.1.1.tgz#f9b7df9b9927b6e6d97c9bd272aa867670f34944"
integrity sha1-+bffm5kntubZfJvScqqGdnDzSUQ=
component-xor@0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/component-xor/-/component-xor-0.0.4.tgz#c55d83ccc1b94cd5089a4e93fa7891c7263e59aa"
integrity sha1-xV2DzMG5TNUImk6T+niRxyY+Wao=
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@ -3165,14 +3155,6 @@ doctypes@^1.1.0:
resolved "https://registry.yarnpkg.com/doctypes/-/doctypes-1.1.0.tgz#ea80b106a87538774e8a3a4a5afe293de489e0a9"
integrity sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk=
dom-iterator@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/dom-iterator/-/dom-iterator-1.0.0.tgz#9c09899846ec41c2d257adc4d6015e4759ef05ad"
integrity sha512-7dsMOQI07EMU98gQM8NSB3GsAiIeBYIPKpnxR3c9xOvdvBjChAcOM0iJ222I3p5xyiZO9e5oggkNaCusuTdYig==
dependencies:
component-props "1.1.1"
component-xor "0.0.4"
dom-serializer@0:
version "0.2.2"
resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.2.2.tgz#1afb81f533717175d478655debc5e332d9f9bb51"
@ -5346,10 +5328,10 @@ jschardet@^2.1.0:
resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-2.1.1.tgz#af6f8fd0b3b0f5d46a8fd9614a4fce490575c184"
integrity sha512-pA5qG9Zwm8CBpGlK/lo2GE9jPxwqRgMV7Lzc/1iaPccw6v4Rhj8Zg2BTyrdmHmxlJojnbLupLeRnaPLsq03x6Q==
jsdom@16.3.0:
version "16.3.0"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.3.0.tgz#75690b7dac36c67be49c336dcd7219bbbed0810c"
integrity sha512-zggeX5UuEknpdZzv15+MS1dPYG0J/TftiiNunOeNxSl3qr8Z6cIlQpN0IdJa44z9aFxZRIVqRncvEhQ7X5DtZg==
jsdom@16.4.0:
version "16.4.0"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-16.4.0.tgz#36005bde2d136f73eee1a830c6d45e55408edddb"
integrity sha512-lYMm3wYdgPhrl7pDcRmvzPhhrGVBeVhPIqeHjzeiHN3DFmD1RBpbExbi8vU7BJdH8VAZYovR8DMt0PNNDM7k8w==
dependencies:
abab "^2.0.3"
acorn "^7.1.1"
@ -7103,10 +7085,10 @@ pg-types@^2.1.0:
postgres-date "~1.0.4"
postgres-interval "^1.1.0"
pg@8.3.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/pg/-/pg-8.3.0.tgz#941383300d38eef51ecb88a0188cec441ab64d81"
integrity sha512-jQPKWHWxbI09s/Z9aUvoTbvGgoj98AU7FDCcQ7kdejupn/TcNpx56v2gaOTzXkzOajmOEJEdi9eTh9cA2RVAjQ==
pg@8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/pg/-/pg-8.3.2.tgz#52766e41302f5b878fe1efa10d4cdd486f6dff50"
integrity sha512-hOoRCTriXS+VWwyXHchRjWb9yv3Koq8irlwwXniqhdgK0AbfWvEnybGS2HIUE+UdCSTuYAM4WGPujFpPg9Vcaw==
dependencies:
buffer-writer "2.0.0"
packet-reader "1.0.0"
@ -7192,6 +7174,11 @@ pngjs@^3.3.0, pngjs@^3.3.1:
resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-3.4.0.tgz#99ca7d725965fb655814eaf65f38f12bbdbf555f"
integrity sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==
portal-vue@2.1.7:
version "2.1.7"
resolved "https://registry.yarnpkg.com/portal-vue/-/portal-vue-2.1.7.tgz#ea08069b25b640ca08a5b86f67c612f15f4e4ad4"
integrity sha512-+yCno2oB3xA7irTt0EU5Ezw22L2J51uKAacE/6hMPMoO/mx3h4rXFkkBkT4GFsMDv/vEe8TNKC3ujJJ0PTwb6g==
portscanner@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/portscanner/-/portscanner-2.2.0.tgz#6059189b3efa0965c9d96a56b958eb9508411cf1"
@ -7884,10 +7871,10 @@ punycode@^1.4.1:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
integrity sha1-wNWmOycYgArY4esPpSachN1BhF4=
pureimage@0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/pureimage/-/pureimage-0.2.4.tgz#7084e6de202beea1b2a4723545efce19266f5cfb"
integrity sha512-8/KkBM3nkUixfjFNw59UQJJ2HFIfiBgL3Cwxtrc9ObVe8yjcUfc/8ZCG0tbQ0qVjnlsCMq6binBueYbIlCb4qA==
pureimage@0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/pureimage/-/pureimage-0.2.5.tgz#10c9d314bcdfba712229ec70c3849164f537c248"
integrity sha512-D/oP8uaS8HLIOPqaxeVU0ZcJHUwvvFjeclKwn0RBeZJn3TBtZgKn7FVBN5auuCHQTC4K/wDAHfkY/JOuGCiohQ==
dependencies:
jpeg-js "^0.4.1"
opentype.js "^0.4.3"
@ -9269,10 +9256,10 @@ syslog-pro@1.0.0:
dependencies:
moment "^2.22.2"
systeminformation@4.26.10:
version "4.26.10"
resolved "https://registry.yarnpkg.com/systeminformation/-/systeminformation-4.26.10.tgz#2244e7529ca9e7b8ecd6941e19fe7df7e3da9146"
integrity sha512-bO4FIzrjESAfh4KHwkUJym3jvKtJ4oJ2PG0BBQGBmKa0pF2oanpkB7CF4ZsSX7vfp3+GKaLzioVwpV/3Tyk+lQ==
systeminformation@4.26.12:
version "4.26.12"
resolved "https://registry.yarnpkg.com/systeminformation/-/systeminformation-4.26.12.tgz#0c6d2c47832b42874dfd5d470d702d7fb5931fa6"
integrity sha512-rO39KsLPxK1UY/s3cgBZz8KUDN7dDgahcgFT2AJaKedo6uKgYHQPdgvhehqNsG+sGBHMUmBwtRUJWgyquEoBHw==
syuilo-password-strength@0.0.1:
version "0.0.1"
@ -9587,10 +9574,10 @@ ts-loader@8.0.2:
micromatch "^4.0.0"
semver "^6.0.0"
ts-node@8.10.2:
version "8.10.2"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d"
integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA==
ts-node@9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-9.0.0.tgz#e7699d2a110cc8c0d3b831715e417688683460b3"
integrity sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==
dependencies:
arg "^4.1.0"
diff "^4.0.1"
@ -9745,10 +9732,10 @@ typeorm@0.2.25:
yargonaut "^1.1.2"
yargs "^13.2.1"
typescript@3.9.7:
version "3.9.7"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
typescript@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2"
integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==
uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.6"
@ -9807,13 +9794,6 @@ undertaker@^1.2.1:
object.reduce "^1.0.0"
undertaker-registry "^1.0.0"
unescape@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/unescape/-/unescape-1.0.1.tgz#956e430f61cad8a4d57d82c518f5e6cc5d0dda96"
integrity sha512-O0+af1Gs50lyH1nUu3ZyYS1cRh01Q/kUKatTOkSs7jukXE6/NebucDVxyiDsA9AQ4JC1V1jUH9EO8JX2nMDgGQ==
dependencies:
extend-shallow "^2.0.1"
union-value@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"
@ -9943,7 +9923,7 @@ uuid@7.0.3:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b"
integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg==
uuid@8.3.0, uuid@^8.2.0:
uuid@8.3.0, uuid@^8.3.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.0.tgz#ab738085ca22dc9a8c92725e459b1d507df5d6ea"
integrity sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==
@ -10156,14 +10136,10 @@ vue-prism-component@1.2.0:
resolved "https://registry.yarnpkg.com/vue-prism-component/-/vue-prism-component-1.2.0.tgz#406252e16979def13b5d28827d95b2b6dc647825"
integrity sha512-0N9CNuQu+36CJpdsZHrhdq7d18oBvjVMjawyKdIr8xuzFWLfdxECZQYbFaYoopPBg3SvkEEMtkhYqdgTQl5Y+A==
vue-prism-editor@0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/vue-prism-editor/-/vue-prism-editor-0.6.1.tgz#e7c5ed39eecd798d2b4a3a6864985e90ed1f0c00"
integrity sha512-UyFLZ242eAplU0C1Tx/ZHSKFTPODQDMBuW9qqgMJyZqHFL2iuIbfT8EWmKtoNUn8w9VWS9IIicPs2odz2eni4Q==
dependencies:
dom-iterator "^1.0.0"
escape-html "^1.0.3"
unescape "^1.0.1"
vue-prism-editor@1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/vue-prism-editor/-/vue-prism-editor-1.2.2.tgz#023cfd4329848f191aac851f2f5e6c7a8c2e059f"
integrity sha512-Lq2VgVygTx3Whn/tC8gD4m1ajA4lzSyCTqPLZA1Dq/ErbBaZA93FWRblwCoDR7AD2nXhGWuiTzb5ih3guzB7DA==
vue-router@4.0.0-beta.7:
version "4.0.0-beta.7"
@ -10210,17 +10186,17 @@ vue@^2.5.13, vue@^2.5.17:
resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.11.tgz#76594d877d4b12234406e84e35275c6d514125c5"
integrity sha512-VfPwgcGABbGAue9+sfrD4PuwFar7gPb1yl1UK1MwXoQPAw0BKSqWfoYCT/ThFrdEVWoI51dBuyCoiNU9bZDZxQ==
vuedraggable@2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/vuedraggable/-/vuedraggable-2.24.0.tgz#1ee069eeb91f61fcb540faf20f1c6b2d4d990a26"
integrity sha512-IlslPpc+iZ2zPNSJbydFZIDrE+don5u+Nc/bjT2YaF+Azidc+wxxJKfKT0NwE68AKk0syb0YbZneAcnynqREZQ==
vuedraggable@2.24.1:
version "2.24.1"
resolved "https://registry.yarnpkg.com/vuedraggable/-/vuedraggable-2.24.1.tgz#304abd7644dde05c1f199a227bf9e9107f56197a"
integrity sha512-G1fxO1oshx+WLdieSGl6jSJdlHOQFga1FpjuUpgXldbpKNzxpjsGn4xYNnRHVrOAqm8aG5FfpdQlh5LHesxCeA==
dependencies:
sortablejs "^1.10.1"
vuex-persistedstate@3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/vuex-persistedstate/-/vuex-persistedstate-3.0.1.tgz#6eacc3c416fe8cfe63c40d3ee7b8ed13aac4f04f"
integrity sha512-2dH77+fIecAXO8GeJEXiYnC++gx48PFGUayB5d7rWrN3fblRCOHQoVnmu/VV9DXbHHJcJth/0W/ofl8vw12j1A==
vuex-persistedstate@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/vuex-persistedstate/-/vuex-persistedstate-3.1.0.tgz#a710d01000bff8336bc3b03fa3ef42e376094b71"
integrity sha512-nRiCe1qDdDrcveFQzTw0QGEj3dRpwN19BailSSwfhe4eUNNQ+9S/ApKnDEAuyw95cigOtSPciMEhdsC0qNUiKQ==
dependencies:
deepmerge "^4.2.2"
shvl "^2.0.0"