Skip to content

Commit

Permalink
Enhance: チャンネルの共同管理者を追加できるように (#12)
Browse files Browse the repository at this point in the history
Enhance: チャンネルの管理者を移転できるように
  • Loading branch information
mattyatea authored Sep 4, 2024
1 parent ca4662f commit ad87be8
Show file tree
Hide file tree
Showing 17 changed files with 428 additions and 357 deletions.
24 changes: 24 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7743,6 +7743,30 @@ export interface Locale extends ILocale {
* チャンネルでの投稿をローカルのみに制限する
*/
"isLocalOnly": string;
/**
* 共同管理者を追加
*/
"addCollaborator": string;
/**
* 共同管理者
*/
"collaborators": string;
/**
* 管理者権限の移譲
*/
"transferAdminConfirmTitle": string;
/**
* このチャンネルの管理者権限を{user}に譲渡しますか?
*/
"transferAdminConfirmDescription": ParameterizedString<"user">;
/**
* このチャンネルの管理者権限を本当に譲渡しますか?
*/
"transferAdminReConfirmDescription": string;
/**
* 危険な設定
*/
"dangerSettings": string;
};
"_menuDisplay": {
/**
Expand Down
7 changes: 7 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,13 @@ _channel:
nameOnly: "名前のみ"
allowRenoteToExternal: "チャンネル外へのリノートと引用リノートを許可する"
isLocalOnly: "チャンネルでの投稿をローカルのみに制限する"
addCollaborator: "共同管理者を追加"
collaborators: "共同管理者"
transferAdminConfirmTitle: "管理者権限の移譲"
transferAdminConfirmDescription: "このチャンネルの管理者権限を{user}に譲渡しますか?"
transferAdminReConfirmDescription: "このチャンネルの管理者権限を本当に譲渡しますか?"
dangerSettings: "危険な設定"


_menuDisplay:
sideFull: ""
Expand Down
9 changes: 5 additions & 4 deletions packages/backend/migration/1725457306200-inboxrule.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Type4ny-project
SPDX-License-Identifier: AGPL-3.0-only
-->
/*
* SPDX-FileCopyrightText: Type4ny-project
* SPDX-License-Identifier: AGPL-3.0-only
*/


export class Inboxrule1725457306200 {
name = 'Inboxrule1725457306200';
Expand Down
16 changes: 16 additions & 0 deletions packages/backend/migration/1725479489061-channelCollaborator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: Type4ny-project
* SPDX-License-Identifier: AGPL-3.0-only
*/

export class ChannelCollaborator1725479489061 {
name = 'ChannelCollaborator1725479489061';

async up(queryRunner) {
await queryRunner.query('ALTER TABLE "channel" ADD "collaboratorIds" jsonb NOT NULL DEFAULT \'[]\'');
}

async down(queryRunner) {
await queryRunner.query('ALTER TABLE "channel" DROP COLUMN "collaboratorIds"');
}
}
12 changes: 11 additions & 1 deletion packages/backend/src/core/entities/ChannelEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@

import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { ChannelFavoritesRepository, ChannelFollowingsRepository, ChannelsRepository, DriveFilesRepository, NotesRepository } from '@/models/_.js';
import type {
ChannelFavoritesRepository,
ChannelFollowingsRepository,
ChannelsRepository,
DriveFilesRepository,
NotesRepository,
UsersRepository,
} from '@/models/_.js';
import type { Packed } from '@/misc/json-schema.js';
import type { } from '@/models/Blocking.js';
import type { MiUser } from '@/models/User.js';
Expand All @@ -15,6 +22,7 @@ import { IdService } from '@/core/IdService.js';
import { DriveFileEntityService } from './DriveFileEntityService.js';
import { NoteEntityService } from './NoteEntityService.js';
import { In } from 'typeorm';
import { UserEntityService } from './UserEntityService.js';

@Injectable()
export class ChannelEntityService {
Expand All @@ -34,6 +42,7 @@ export class ChannelEntityService {
@Inject(DI.driveFilesRepository)
private driveFilesRepository: DriveFilesRepository,

private userEntityService: UserEntityService,
private noteEntityService: NoteEntityService,
private driveFileEntityService: DriveFileEntityService,
private idService: IdService,
Expand Down Expand Up @@ -87,6 +96,7 @@ export class ChannelEntityService {
isSensitive: channel.isSensitive,
allowRenoteToExternal: channel.allowRenoteToExternal,
isLocalOnly: channel.isLocalOnly,
collaboratorUsers: channel.collaboratorIds.length > 0 ? await this.userEntityService.packMany(channel.collaboratorIds) : [],
...(me ? {
isFollowing,
isFavorited,
Expand Down
6 changes: 5 additions & 1 deletion packages/backend/src/models/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export class MiChannel {
})
public isSensitive: boolean;


@Column('boolean', {
default: false,
})
Expand All @@ -104,4 +103,9 @@ export class MiChannel {
default: true,
})
public allowRenoteToExternal: boolean;

@Column('jsonb', {
default: [],
})
public collaboratorIds: string[];
}
1 change: 1 addition & 0 deletions packages/backend/src/models/SystemWebhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const systemWebhookEventTypes = [
'customEmojiRequestResolved',
// ユーザが登録したとき
'userRegistered',
'userCreated',
] as const;
export type SystemWebhookEventType = typeof systemWebhookEventTypes[number];

Expand Down
13 changes: 11 additions & 2 deletions packages/backend/src/models/json-schema/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ export const packedChannelSchema = {
ref: 'Note',
},
},
isLocalOnly:{
isLocalOnly: {
type: 'boolean',
optional: false, nullable: true,
}
},
collaboratorUsers: {
type: 'array',
optional: false, nullable: true,
items: {
type: 'object',
optional: false, nullable: false,
ref: 'User',
},
},
},
} as const;
17 changes: 17 additions & 0 deletions packages/backend/src/models/json-schema/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@ export const packedMetaLiteSchema = {
optional: false,
nullable: true,
},
backgroundImageUrls: {
type: 'array',
optional: false,
nullable: false,
items: {
type: 'object',
optional: false,
nullable: false,
properties: {
url: {
type: 'string',
optional: false,
nullable: false,
},
},
},
},
mcaptchaInstanceUrl: {
type: 'string',
optional: false,
Expand Down
Loading

0 comments on commit ad87be8

Please sign in to comment.