feat: local-only antenna

Resolve #11869
This commit is contained in:
syuilo
2023-10-16 15:06:00 +09:00
parent 6a321ba340
commit 3ebed5aa3e
15 changed files with 47 additions and 3 deletions

View File

@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class AntennaLocalOnly1697436246389 {
name = 'AntennaLocalOnly1697436246389'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "antenna" ADD "localOnly" boolean NOT NULL DEFAULT false`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "antenna" DROP COLUMN "localOnly"`);
}
}

View File

@@ -98,6 +98,8 @@ export class AntennaService implements OnApplicationShutdown {
if (note.visibility === 'specified') return false;
if (note.visibility === 'followers') return false;
if (antenna.localOnly && noteUser.host != null) return false;
if (!antenna.withReplies && note.replyId != null) return false;
if (antenna.src === 'home') {

View File

@@ -37,6 +37,7 @@ export class AntennaEntityService {
userListId: antenna.userListId,
users: antenna.users,
caseSensitive: antenna.caseSensitive,
localOnly: antenna.localOnly,
notify: antenna.notify,
withReplies: antenna.withReplies,
withFile: antenna.withFile,

View File

@@ -93,4 +93,9 @@ export class MiAntenna {
default: true,
})
public isActive: boolean;
@Column('boolean', {
default: false,
})
public localOnly: boolean;
}

View File

@@ -67,6 +67,11 @@ export const packedAntennaSchema = {
optional: false, nullable: false,
default: false,
},
localOnly: {
type: 'boolean',
optional: false, nullable: false,
default: false,
},
notify: {
type: 'boolean',
optional: false, nullable: false,

View File

@@ -80,6 +80,7 @@ export class ExportAntennasProcessorService {
return this.utilityService.getFullApAccount(u.username, u.host); // acct
}) : null,
caseSensitive: antenna.caseSensitive,
localOnly: antenna.localOnly,
withReplies: antenna.withReplies,
withFile: antenna.withFile,
notify: antenna.notify,

View File

@@ -43,6 +43,7 @@ const validate = new Ajv().compile({
type: 'string',
} },
caseSensitive: { type: 'boolean' },
localOnly: { type: 'boolean' },
withReplies: { type: 'boolean' },
withFile: { type: 'boolean' },
notify: { type: 'boolean' },
@@ -86,6 +87,7 @@ export class ImportAntennasProcessorService {
excludeKeywords: antenna.excludeKeywords,
users: (antenna.src === 'list' && antenna.userListAccts !== null ? antenna.userListAccts : antenna.users).filter(Boolean),
caseSensitive: antenna.caseSensitive,
localOnly: antenna.localOnly,
withReplies: antenna.withReplies,
withFile: antenna.withFile,
notify: antenna.notify,

View File

@@ -63,6 +63,7 @@ export const paramDef = {
type: 'string',
} },
caseSensitive: { type: 'boolean' },
localOnly: { type: 'boolean' },
withReplies: { type: 'boolean' },
withFile: { type: 'boolean' },
notify: { type: 'boolean' },
@@ -122,6 +123,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
excludeKeywords: ps.excludeKeywords,
users: ps.users,
caseSensitive: ps.caseSensitive,
localOnly: ps.localOnly,
withReplies: ps.withReplies,
withFile: ps.withFile,
notify: ps.notify,

View File

@@ -62,6 +62,7 @@ export const paramDef = {
type: 'string',
} },
caseSensitive: { type: 'boolean' },
localOnly: { type: 'boolean' },
withReplies: { type: 'boolean' },
withFile: { type: 'boolean' },
notify: { type: 'boolean' },
@@ -116,6 +117,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
excludeKeywords: ps.excludeKeywords,
users: ps.users,
caseSensitive: ps.caseSensitive,
localOnly: ps.localOnly,
withReplies: ps.withReplies,
withFile: ps.withFile,
notify: ps.notify,

View File

@@ -188,6 +188,7 @@ describe('Account Move', () => {
excludeKeywords: [],
users: [],
caseSensitive: false,
localOnly: false,
withReplies: false,
withFile: false,
notify: false,
@@ -431,6 +432,7 @@ describe('Account Move', () => {
excludeKeywords: [],
users: [eve.id],
caseSensitive: false,
localOnly: false,
withReplies: false,
withFile: false,
notify: false,