Skip to content

Commit

Permalink
Merge tag '10.102.690-m544' into custom/atsuchan
Browse files Browse the repository at this point in the history
10.102.690-m544
  • Loading branch information
atsu1125 committed Feb 19, 2024
2 parents 62ee7f4 + a6c53c5 commit 2167f76
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 26 deletions.
5 changes: 3 additions & 2 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1525,8 +1525,7 @@ admin/views/instance.vue:
smtp-auth: "Perform SMTP authentication"
smtp-user: "SMTP User"
smtp-pass: "SMTP Password"
test-email-address: "Test mail address"
test-mail: "Send Test mail"
test-mail: "Test mail"
serviceworker-config: "ServiceWorker"
enable-serviceworker: "Enable ServiceWorker"
serviceworker-info: "Must be enabled for push notifications."
Expand Down Expand Up @@ -1786,6 +1785,8 @@ admin/views/instanceblocks.vue:
silencedInstances-info: "Instances to recieve with maximum visibility home. One host per line. You can use /RegExp/."
selfSilencedInstances: "Self-silenced instances"
selfSilencedInstances-info: "Instances to deliver with maximum visibility home. One host per line. You can use /RegExp/."
mutedFiles: "Attachments to mute"
mutedFiles-info: "Mute the specified file if it is attached. MD5 lower case."
exposeHome: "If fetched from remote, max visibility to home."
exposeHome-info: "If posts are retrieved from instances with no followers, etc., set the maximum visibility to Home."

Expand Down
5 changes: 3 additions & 2 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1675,8 +1675,7 @@ admin/views/instance.vue:
smtp-auth: "SMTP認証を行う"
smtp-user: "SMTPユーザー"
smtp-pass: "SMTPパスワード"
test-email-address: "テストメールの送信先"
test-mail: "テストメールを送信"
test-mail: "テスト送信"
serviceworker-config: "ServiceWorker"
enable-serviceworker: "ServiceWorkerを有効にする"
serviceworker-info: "プッシュ通知を行うには有効する必要があります。"
Expand Down Expand Up @@ -1949,6 +1948,8 @@ admin/views/instanceblocks.vue:
silencedInstances-info: "最大公開範囲ホームで受信するインスタンス。1行に1ホスト記述します。/正規表現/ が使えます。"
selfSilencedInstances: "セルフサイレンスするインスタンス"
selfSilencedInstances-info: "最大公開範囲ホームで配信するインスタンス。1行に1ホスト記述します。/正規表現/ が使えます。"
mutedFiles: "ミュートする添付ファイル"
mutedFiles-info: "指定のファイルが投稿に添付されている場合にミュートします。MD5小文字。"
exposeHome: 取得されるときの最大公開範囲はホームにする
exposeHome-info: "フォロワーのいないインスタンスなどから投稿を取得されるときの最大公開範囲をホームにします。"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "misskey",
"author": "mei23 <[email protected]>",
"version": "10.102.689-m544",
"version": "10.102.690-m544",
"codename": "m544",
"repository": {
"type": "git",
Expand Down
22 changes: 11 additions & 11 deletions src/client/app/admin/views/cards/email.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<ui-input v-model="smtpPass" type="password" :withPasswordToggle="true" :disabled="!enableEmail || !smtpAuth">{{ $t('smtp-pass') }}</ui-input>
</ui-horizon-group>
<ui-switch v-model="smtpSecure" :disabled="!enableEmail || !$store.getters.isAdmin">{{ $t('smtp-secure') }}<template #desc>{{ $t('smtp-secure-info') }}</template></ui-switch>
<ui-input v-model="testEmailAddress" type="email" :disabled="!enableEmail"><template #icon><fa :icon="farEnvelope"/></template>{{ $t('test-email-address') }}</ui-input>
<ui-button @click="testEmail()" :disabled="!$store.getters.isAdmin">{{ $t('test-mail') }}</ui-button>
</section>
<!-- save -->
Expand Down Expand Up @@ -57,9 +56,6 @@ export default defineComponent({
smtpUser: null,
smtpPass: null,
smtpAuth: false,
testEmailAddress: null,
maintainerEmail: null,
// icons アイコンを追加したらここをいじる 2/2
farEnvelope,
Expand All @@ -84,9 +80,6 @@ export default defineComponent({
this.smtpUser = meta.smtpUser;
this.smtpPass = meta.smtpPass;
this.smtpAuth = meta.smtpUser != null && meta.smtpUser !== '';
this.testEmailAddress = meta.testEmailAddress;
this.maintainerEmail = meta.maintainer.email;
});
},
Expand All @@ -108,7 +101,6 @@ export default defineComponent({
smtpPort: parseInt(this.smtpPort, 10),
smtpUser: this.smtpAuth ? this.smtpUser : '',
smtpPass: this.smtpAuth ? this.smtpPass : '',
testEmailAddress: this.testEmailAddress,
}).then(() => {
this.fetchMeta();
this.$root.dialog({
Expand All @@ -124,10 +116,18 @@ export default defineComponent({
},
async testEmail() {
const { canceled, result } = await this.$root.dialog({
title: 'To',
input: {
type: 'text'
}
});
if (canceled) return;
this.$root.api('admin/send-email', {
to: this.testEmailAddress,
subject: 'Test email from Misskey',
text: 'Test email from your Misskey instance.'
to: result,
subject: 'Test email',
text: 'Na'
}).then((e: Error) => {
this.$root.dialog({
type: 'success',
Expand Down
8 changes: 4 additions & 4 deletions src/client/app/admin/views/cards/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
</section>
<!-- maintainer -->
<section class="fit-bottom">
<header><fa :icon="faHeadset"/> {{ $t('maintainer-config') }}</header>
<header><fa :icon="faCrown"/> {{ $t('maintainer-config') }}</header>
<ui-horizon-group inputs>
<ui-input v-model="maintainerName">{{ $t('maintainer-name') }}</ui-input>
<ui-input v-model="maintainerEmail" type="email"><template #icon><fa :icon="farEnvelope"/></template>{{ $t('maintainer-email') }}</ui-input>
<ui-input v-model="maintainerEmail" type="text">{{ $t('maintainer-email') }}</ui-input>
</ui-horizon-group>
</section>
<!-- extra -->
Expand All @@ -42,7 +42,7 @@ import { defineComponent, getCurrentInstance } from 'vue';
import i18n from '../../../i18n';
// アイコンを追加したらここをいじる 1/2
import { faHeadset } from '@fortawesome/free-solid-svg-icons';
import { faCrown } from '@fortawesome/free-solid-svg-icons';
import { faEnvelope as farEnvelope } from '@fortawesome/free-regular-svg-icons';
export default defineComponent({
Expand All @@ -68,7 +68,7 @@ export default defineComponent({
disableInvitation: false,
// icons アイコンを追加したらここをいじる 2/2
faHeadset, farEnvelope,
faCrown, farEnvelope,
};
},
Expand Down
9 changes: 9 additions & 0 deletions src/client/app/admin/views/instanceblocks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<ui-info>{{ $t('selfSilencedInstances-info') }}</ui-info>
</section>

<section>
<header>{{ $t('mutedFiles') }}</header>
<ui-textarea v-model="mutedFiles"></ui-textarea>
<ui-info>{{ $t('mutedFiles-info') }}</ui-info>
</section>

<section>
<ui-switch v-model="exposeHome">{{ $t('exposeHome') }}</ui-switch>
<ui-info>{{ $t('exposeHome-info') }}</ui-info>
Expand All @@ -45,6 +51,7 @@ export default defineComponent({
blockedInstances: '',
silencedInstances: '',
selfSilencedInstances: '',
mutedFiles: '',
exposeHome: false,
};
},
Expand All @@ -57,6 +64,7 @@ export default defineComponent({
this.blockedInstances = meta.blockedInstances.join('\n');
this.silencedInstances = meta.silencedInstances.join('\n');
this.selfSilencedInstances = meta.selfSilencedInstances.join('\n');
this.mutedFiles = meta.mutedFiles.join('\n');
this.exposeHome = meta.exposeHome;
});
},
Expand All @@ -65,6 +73,7 @@ export default defineComponent({
blockedInstances: this.blockedInstances ? this.blockedInstances.split('\n') : [],
silencedInstances: this.silencedInstances ? this.silencedInstances.split('\n') : [],
selfSilencedInstances: this.selfSilencedInstances ? this.selfSilencedInstances.split('\n') : [],
mutedFiles: this.mutedFiles ? this.mutedFiles.split('\n') : [],
exposeHome: !!this.exposeHome,
}).then(() => {
this.$root.dialog({
Expand Down
5 changes: 4 additions & 1 deletion src/client/app/common/views/deck/deck.user-column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ export default Vue.extend({
this.$root.api('users/show', parseAcct(this.$route.params.user)).then(user => {
this.user = user;
this.fetching = false;
});
}).catch((e: any) => {
this.$root.dialog({ type: 'error', text: e.message || 'Error' });
this.fetching = false;
});;
},
onAvatarClick() {
Expand Down
3 changes: 2 additions & 1 deletion src/client/app/desktop/views/home/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ export default Vue.extend({
if (this.$store.state.i || !user.host) this.user = user;
this.fetching = false;
Progress.done();
}).catch(() => {
}).catch((e: any) => {
this.$root.dialog({ type: 'error', text: e.message || 'Error' });
this.fetching = false;
Progress.done();
});
Expand Down
4 changes: 4 additions & 0 deletions src/client/app/mobile/views/pages/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export default Vue.extend({
Progress.done();
document.title = `${Vue.filter('userName')(this.user)} | ${this.$root.instanceName}`;
}).catch((e: any) => {
this.$root.dialog({ type: 'error', text: e.message || 'Error' });
this.fetching = false;
Progress.done();
});
},
Expand Down
1 change: 1 addition & 0 deletions src/misc/fetch-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const defaultMeta: any = {
blockedInstances: [],
silencedInstances: [],
selfSilencedInstances: [],
mutedFiles: [],
exposeHome: false,
stats: {
// Object.assignじゃマージされない
Expand Down
1 change: 1 addition & 0 deletions src/models/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export type IMeta = {
blockedInstances?: string[];
silencedInstances?: string[];
selfSilencedInstances?: string[];
mutedFiles?: string[];
exposeHome?: boolean;
mascotImageUrl?: string;
bannerUrl?: string;
Expand Down
1 change: 1 addition & 0 deletions src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export default define(meta, async (ps, me) => {
response.blockedInstances = instance.blockedInstances;
response.silencedInstances = instance.silencedInstances;
response.selfSilencedInstances = instance.selfSilencedInstances;
response.mutedFiles = instance.mutedFiles;
response.exposeHome = instance.exposeHome;
response.recaptchaSecretKey = instance.recaptchaSecretKey;
response.proxyAccount = instance.proxyAccount;
Expand Down
15 changes: 13 additions & 2 deletions src/server/api/endpoints/admin/update-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export const meta = {
}
},

mutedFiles: {
validator: $.optional.nullable.arr($.str),
desc: {
'ja-JP': 'ミュートする添付ファイル'
}
},

exposeHome: {
validator: $.optional.boolean,
desc: {
Expand Down Expand Up @@ -223,7 +230,7 @@ export const meta = {
maintainerEmail: {
validator: $.optional.nullable.str,
desc: {
'ja-JP': 'インスタンス管理者の連絡先メールアドレス'
'ja-JP': 'インスタンス管理者の連絡先'
}
},

Expand Down Expand Up @@ -442,6 +449,10 @@ export default define(meta, async (ps) => {
set.selfSilencedInstances = ps.selfSilencedInstances.map(x => x.trim()).filter(x => x !== '').map(x => toApHost(x));
}

if (Array.isArray(ps.mutedFiles)) {
set.mutedFiles = ps.mutedFiles.map(x => x.trim()).filter(x => x !== '');
}

if (typeof ps.exposeHome === 'boolean') {
set.exposeHome = ps.exposeHome;
}
Expand Down Expand Up @@ -598,7 +609,7 @@ export default define(meta, async (ps) => {
$set: set
}, { upsert: true });

if (set.blockedInstances || set.silencedInstances || set.selfSilencedInstances) {
if (set.blockedInstances || set.silencedInstances || set.selfSilencedInstances || set.mutedFiles) {
publishInstanceModUpdated();
}

Expand Down
18 changes: 18 additions & 0 deletions src/services/instance-moderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let silencedHostsRegExp: Set<RegExp>;
let selfSilencedHosts: Set<string>;
let selfSilencedHostsRegExp: Set<RegExp>;
let closedHosts: Set<string>;
let mutedFiles: Set<string>;

export async function isBlockedHost(host: string | null) {
if (host == null) return false;
Expand Down Expand Up @@ -44,6 +45,12 @@ export async function isSelfSilencedHost(host: string | null) {
return false;
}

export async function isMutedFile(md5: string | null | undefined) {
if (md5 == null) return false;
if (!mutedFiles) await Update();
return mutedFiles?.has(md5);
}

export async function isClosedHost(host: string | null) {
if (host == null) return false;
if (!closedHosts) await Update();
Expand Down Expand Up @@ -111,6 +118,17 @@ async function Update() {
selfSilencedHostsRegExp = regExps;
}

// mutedFiles from meta
{
const literals = new Set<string>();

for (const b of (meta.mutedFiles || [])) {
literals.add(b);
}

mutedFiles = literals;
}

// closed from instance
const closed = await Instance.find({
isMarkedAsClosed: true
Expand Down
12 changes: 12 additions & 0 deletions src/services/note/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import { IActivity } from '../../remote/activitypub/type';
import { normalizeTag } from '../../misc/normalize-tag';
import * as ms from 'ms';
import { isSilencedHost } from '../../services/instance-moderation'
import { isMutedFile } from '../instance-moderation';
import Logger from '../logger';
export const noteLogger = new Logger('note');

type NotificationType = 'reply' | 'renote' | 'quote' | 'mention' | 'highlight';

Expand Down Expand Up @@ -85,6 +88,15 @@ class NotificationManager {
return;
}

if (this.queue.length === 0) return;

for (const atc of this.note._files || []) {
if (await isMutedFile(atc.md5)) {
noteLogger.info(`muted file: note=${this.note._id} md5=${atc.md5}`);
return;
}
}

for (const x of this.queue) {
// ミュートされてたらスキップ
const mute = await getMute(x.target, this.notifier._id);
Expand Down
7 changes: 6 additions & 1 deletion src/tools/_delete-deleted-user-by-hosts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 消したリモートユーザーを物理削除する、削除フラグリセット、clean-deleted-user-objsをやった後にやる、使うな
// 消したリモートユーザーを物理削除する by host
import Note from '../models/note';
import User, { IUser } from '../models/user';

async function main(host: string) {
Expand All @@ -23,6 +24,10 @@ async function main(host: string) {

console.log(`user(${prs}/${users.length}): ${user.username}@${user.host}`);

await Note.remove({
userId: user._id
});

await User.remove({
_id: u._id
});
Expand Down
7 changes: 6 additions & 1 deletion src/tools/_delete-deleted-user-by-id.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 消したリモートユーザーを物理削除する、削除フラグリセット、clean-deleted-user-objsをやった後にやる、使うな
// 消したリモートユーザーを物理削除する by UserId
import * as mongo from 'mongodb';
import User from '../models/user';
import Note from '../models/note';

async function main(userId: string) {
if (!userId) throw 'userId required';
Expand All @@ -16,6 +17,10 @@ async function main(userId: string) {

console.log('user', user);

await Note.remove({
userId: user._id
});

await User.remove({
_id: user._id
});
Expand Down

0 comments on commit 2167f76

Please sign in to comment.