forked from FoundKeyGang/FoundKey
backend: implement not forwarding block activities
Each user can select if they want their block & unblock activities to be forwarded or not. Changelog: Added
This commit is contained in:
parent
ca90cedba0
commit
5038eb3ac4
8 changed files with 33 additions and 3 deletions
|
@ -740,6 +740,8 @@ unknown: "不明"
|
|||
onlineStatus: "オンライン状態"
|
||||
hideOnlineStatus: "オンライン状態を隠す"
|
||||
hideOnlineStatusDescription: "オンライン状態を隠すと、検索などの一部機能において利便性が低下することがあります。"
|
||||
federateBlocks: "ブロックを連合に送信"
|
||||
federateBlocksDescription: "オフにするとBlockのActivityは連合に送信しません"
|
||||
online: "オンライン"
|
||||
active: "アクティブ"
|
||||
offline: "オフライン"
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import {MigrationInterface, QueryRunner} from "typeorm";
|
||||
|
||||
export class userBlockFederation1631880003000 implements MigrationInterface {
|
||||
name = 'userBlockFederation1631880003000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "user" ADD "federateBlocks" boolean NOT NULL DEFAULT true`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "federateBlocks"`);
|
||||
}
|
||||
|
||||
}
|
|
@ -218,6 +218,11 @@ export class User {
|
|||
})
|
||||
public token: string | null;
|
||||
|
||||
@Column('boolean', {
|
||||
default: true,
|
||||
})
|
||||
public federateBlocks: boolean;
|
||||
|
||||
constructor(data: Partial<User>) {
|
||||
if (data == null) return;
|
||||
|
||||
|
|
|
@ -335,6 +335,7 @@ export const UserRepository = db.getRepository(User).extend({
|
|||
isLocked: user.isLocked,
|
||||
isSilenced: user.isSilenced || falsy,
|
||||
isSuspended: user.isSuspended || falsy,
|
||||
federateBlocks: user!.federateBlocks,
|
||||
description: profile!.description,
|
||||
location: profile!.location,
|
||||
birthday: profile!.birthday,
|
||||
|
|
|
@ -81,6 +81,7 @@ export const paramDef = {
|
|||
emailNotificationTypes: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
federateBlocks: { type: 'boolean' },
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
@ -129,6 +130,7 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
|||
if (typeof ps.carefulBot === 'boolean') profileUpdates.carefulBot = ps.carefulBot;
|
||||
if (typeof ps.autoAcceptFollowed === 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
|
||||
if (typeof ps.noCrawle === 'boolean') profileUpdates.noCrawle = ps.noCrawle;
|
||||
if (typeof ps.federateBlocks === 'boolean') updates.federateBlocks = ps.federateBlocks;
|
||||
if (typeof ps.isCat === 'boolean') updates.isCat = ps.isCat;
|
||||
if (typeof ps.injectFeaturedNote === 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
|
||||
if (typeof ps.receiveAnnouncementEmail === 'boolean') profileUpdates.receiveAnnouncementEmail = ps.receiveAnnouncementEmail;
|
||||
|
|
|
@ -32,7 +32,7 @@ export default async function(blocker: User, blockee: User) {
|
|||
|
||||
await Blockings.insert(blocking);
|
||||
|
||||
if (Users.isLocalUser(blocker) && Users.isRemoteUser(blockee)) {
|
||||
if (Users.isLocalUser(blocker) && Users.isRemoteUser(blockee) && blocker.federateBlocks) {
|
||||
const content = renderActivity(renderBlock(blocking));
|
||||
deliver(blocker, content, blockee.inbox);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ export default async function(blocker: CacheableUser, blockee: CacheableUser) {
|
|||
Blockings.delete(blocking.id);
|
||||
|
||||
// deliver if remote bloking
|
||||
if (Users.isLocalUser(blocker) && Users.isRemoteUser(blockee)) {
|
||||
if (Users.isLocalUser(blocker) && Users.isRemoteUser(blockee) && blocker.federateBlocks) {
|
||||
const content = renderActivity(renderUndo(renderBlock(blocking), blocker));
|
||||
deliver(blocker, content, blockee.inbox);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
{{ i18n.ts.makeExplorable }}
|
||||
<template #caption>{{ i18n.ts.makeExplorableDescription }}</template>
|
||||
</FormSwitch>
|
||||
<FormSwitch v-model="federateBlocks" @update:value="save()">
|
||||
{{ $ts.federateBlocks }}
|
||||
<template #caption>{{ $ts.federateBlocksDescription }}</template>
|
||||
</FormSwitch>
|
||||
|
||||
<FormSection>
|
||||
<FormFolder class="_formBlock">
|
||||
|
@ -69,12 +73,13 @@ let isExplorable = $ref($i.isExplorable);
|
|||
let hideOnlineStatus = $ref($i.hideOnlineStatus);
|
||||
let publicReactions = $ref($i.publicReactions);
|
||||
let ffVisibility = $ref($i.ffVisibility);
|
||||
let federateBlocks = $ref($i.federateBlocks);
|
||||
|
||||
let defaultNoteVisibility = $computed(defaultStore.makeGetterSetter('defaultNoteVisibility'));
|
||||
let defaultNoteLocalOnly = $computed(defaultStore.makeGetterSetter('defaultNoteLocalOnly'));
|
||||
let keepCw = $computed(defaultStore.makeGetterSetter('keepCw'));
|
||||
|
||||
function save() {
|
||||
function save(): void {
|
||||
os.api('i/update', {
|
||||
isLocked: !!isLocked,
|
||||
autoAcceptFollowed: !!autoAcceptFollowed,
|
||||
|
@ -83,6 +88,7 @@ function save() {
|
|||
hideOnlineStatus: !!hideOnlineStatus,
|
||||
publicReactions: !!publicReactions,
|
||||
ffVisibility,
|
||||
federateBlocks,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue