Skip to content

Commit

Permalink
Merge pull request #141 from n1lsqn/feat/defaultTimeline
Browse files Browse the repository at this point in the history
feat: デフォルトで表示されるタイムラインを変える(GTLがあるサーバー向け)
  • Loading branch information
n1lsqn authored Aug 26, 2024
2 parents b116c11 + 88a5392 commit 4f39a4c
Show file tree
Hide file tree
Showing 25 changed files with 135 additions and 550 deletions.
32 changes: 32 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5246,10 +5246,13 @@ export interface Locale extends ILocale {
"section3": string;
};
};
<<<<<<< HEAD
/**
* 自動生成
*/
"autoGenerated": string;
=======
>>>>>>> parent of ffceadae73 ((add) 緊急お知らせ・津波情報連携)
"_announcement": {
/**
* 既存ユーザーのみ
Expand Down Expand Up @@ -10289,6 +10292,7 @@ export interface Locale extends ILocale {
* サーバーに接続できません
*/
"header": string;
<<<<<<< HEAD
};
"_emergencyAnnouncement": {
"_admin": {
Expand Down Expand Up @@ -10389,6 +10393,8 @@ export interface Locale extends ILocale {
"description": string;
};
};
=======
>>>>>>> parent of ffceadae73 ((add) 緊急お知らせ・津波情報連携)
};
"_urlPreviewSetting": {
/**
Expand Down Expand Up @@ -10514,6 +10520,32 @@ export interface Locale extends ILocale {
*/
"native": string;
};
"_defaultTimeline": {
/**
* デフォルトタイムライン
*/
"title": string;
/**
* デフォルトで表示されるタイムラインを設定します。
*/
"description": string;
/**
* ホーム
*/
"home": string;
/**
* ローカル
*/
"local": string;
/**
* ソーシャル
*/
"social": string;
/**
* グローバル
*/
"global": string;
};
}
declare const locales: {
[lang: string]: Locale;
Expand Down
40 changes: 8 additions & 32 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,6 @@ _bubbleGame:
section1: "位置を調整してハコにモノを落とします。"
section2: "同じ種類のモノがくっつくと別のモノに変化して、スコアが得られます。"
section3: "モノがハコからあふれるとゲームオーバーです。ハコからあふれないようにしつつモノを融合させてハイスコアを目指そう!"
autoGenerated: "自動生成"

_announcement:
forExistingUsers: "既存ユーザーのみ"
Expand Down Expand Up @@ -2741,37 +2740,6 @@ _offlineScreen:
title: "オフライン - サーバーに接続できません"
header: "サーバーに接続できません"

_emergencyAnnouncement:
_admin:
label: "緊急"
labelCaption: "「緊急」は、災害や身辺の安全に関わる情報にのみ使用し、他の用途には絶対に使用しないでください。「緊急」では、お知らせが特に目立つように表示されるほか、お知らせとともに「緊急時のMisskeyの使用について」の情報が表示されます。アクティブな「緊急」お知らせはひとつしか作成できません。"
autoGenWarn: "緊急情報の外部連携機能の管理のための特殊タイトルです。タイトルは書き換えできますが、書き換えた場合、連携機能が外れ、自動でアーカイブされなくなります。書き換える場合は必ず手動でアーカイブすることを忘れないようにしてください。"
hasEmergencyAnnouncement: "「緊急」お知らせが有効です。"
hasEmergencyAnnouncementLong: "「緊急」お知らせが有効です。緊急事態が収束したら、忘れず削除してください。自動連携を使用している場合、有効な「緊急」お知らせがある間は連携が停止されます。"
_integration:
title: "緊急情報の外部連携"
switch: "「緊急」お知らせの外部連携"
intgType: "緊急情報プロバイダー"
_integrator:
_p2pquake:
info: "p2pquake: 日本国内に津波注意報・津波警報・大津波警報が発令されている間はお知らせを表示します。自動生成されたお知らせのタイトル(__PROVIDER_p2pquake__)が変更されなかった場合は、解除され次第、お知らせをアーカイブします。"
_providerLabel:
none: "身辺の安全に関わる情報あり"
p2pquake: "津波情報が発令中"
_providerBody:
none: "身の危険が差し迫っている可能性があります。信頼できる情報源から最新の情報を入手し、命を守る行動をお取りください。"
p2pquake: "日本国内で津波注意報・津波警報・大津波警報のいずれかが発令されています。該当の地域の方は海岸の近くから離れてください。"
_misskeyInEmergency:
title: "緊急時のMisskeyの使用について"
description: "MisskeyはリッチなWeb UIを提供していますが、ご利用中の環境や設定によっては電池や通信量を大量に消費してしまうことがあります。そのため、緊急事態の際は以下のように使用することをおすすめします。"
_doNotUseMisskey:
title: "なるべくMisskeyの利用を控えてください。"
description: "災害時はサーバーがアクティブになり、新着ノートの量が増え、それにより電池やデータ通信量を通常より多く消費してしまうことが予想されます。安全な場所で確実に充電が可能になるまでは、Misskeyの利用をなるべく控えてください。"
youCanUseCli: "Misskeyにログインした状態で{link}を開くと、簡易クライアントを利用することができます(上級者向け)。"
_closeMisskeyCompletely:
title: "Misskeyを閉じるときは、タブごと閉じるようにしてください。"
description: "ブラウザのタブを閉じずに、ブラウザのアプリだけを終了してしまうと、Misskeyがバックグラウンドで通信し続ける可能性があります。必ずタブを閉じてください。PWA(アプリモード)でお使いの場合は、タスクキルをお忘れなく。"

_urlPreviewSetting:
title: "URLプレビューの設定"
enable: "URLプレビューを有効にする"
Expand Down Expand Up @@ -2808,3 +2776,11 @@ _contextMenu:
app: "アプリケーション"
appWithShift: "Shiftキーでアプリケーション"
native: "ブラウザのUI"

_defaultTimeline:
title: "デフォルトタイムライン"
description: "デフォルトで表示されるタイムラインを設定します。"
home: "ホーム"
local: "ローカル"
social: "ソーシャル"
global: "グローバル"

This file was deleted.

2 changes: 0 additions & 2 deletions packages/backend/src/boot/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { NestLogger } from '@/NestLogger.js';
import { QueueProcessorModule } from '@/queue/QueueProcessorModule.js';
import { QueueStatsService } from '@/daemons/QueueStatsService.js';
import { ServerStatsService } from '@/daemons/ServerStatsService.js';
import { EmergencyAnnouncementService } from '@/daemons/EmergencyAnnouncementService.js';
import { ServerService } from '@/server/ServerService.js';
import { MainModule } from '@/MainModule.js';

Expand All @@ -26,7 +25,6 @@ export async function server() {
app.get(ChartManagementService).start();
app.get(QueueStatsService).start();
app.get(ServerStatsService).start();
app.get(EmergencyAnnouncementService).start();
}

return app;
Expand Down
3 changes: 0 additions & 3 deletions packages/backend/src/daemons/DaemonModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { CoreModule } from '@/core/CoreModule.js';
import { GlobalModule } from '@/GlobalModule.js';
import { QueueStatsService } from './QueueStatsService.js';
import { ServerStatsService } from './ServerStatsService.js';
import { EmergencyAnnouncementService } from './EmergencyAnnouncementService.js';

@Module({
imports: [
Expand All @@ -18,12 +17,10 @@ import { EmergencyAnnouncementService } from './EmergencyAnnouncementService.js'
providers: [
QueueStatsService,
ServerStatsService,
EmergencyAnnouncementService,
],
exports: [
QueueStatsService,
ServerStatsService,
EmergencyAnnouncementService,
],
})
export class DaemonModule {}
97 changes: 0 additions & 97 deletions packages/backend/src/daemons/EmergencyAnnouncementService.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/backend/src/models/Announcement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class MiAnnouncement {
// normal ... お知らせページ掲載
// banner ... お知らせページ掲載 + バナー表示
// dialog ... お知らせページ掲載 + ダイアログ表示
// emergency ... (緊急防災情報)お知らせページ掲載 + バナー表示 + 専用ダイアログ表示
@Column('varchar', {
length: 256, nullable: false,
default: 'normal',
Expand Down
18 changes: 0 additions & 18 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,24 +611,6 @@ export class MiMeta {
})
public notesPerOneAd: number;

@Column('boolean', {
default: false,
})
public enableEmergencyAnnouncementIntegration: boolean;

// p2pquake以外のプロバイダーを追加する場合は、この型を拡張する
// 必要に応じて型内にフィールドを追加する
@Column('jsonb', {
default: {
type: 'none',
},
})
public emergencyAnnouncementIntegrationConfig: {
type: 'none',
} | {
type: 'p2pquake',
};

@Column('boolean', {
default: true,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import { Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { AnnouncementService } from '@/core/AnnouncementService.js';
import type { AnnouncementsRepository } from '@/models/_.js';
import { ApiError } from '../../../error.js';

export const meta = {
tags: ['admin'],
Expand Down Expand Up @@ -51,14 +48,6 @@ export const meta = {
},
},
},

errors: {
cannotMakeMoreEmergencyAnnouncement: {
message: 'You cannot create more than one Emergency Announcement.',
code: 'TOO_MANY_EMERGENCY_ANNOUNCEMENT',
id: 'f57c4255-81b2-4094-9e38-ab5c006b66bd',
},
},
} as const;

export const paramDef = {
Expand All @@ -68,7 +57,7 @@ export const paramDef = {
text: { type: 'string', minLength: 1 },
imageUrl: { type: 'string', nullable: true, minLength: 1 },
icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'], default: 'info' },
display: { type: 'string', enum: ['normal', 'banner', 'dialog', 'emergency'], default: 'normal' },
display: { type: 'string', enum: ['normal', 'banner', 'dialog'], default: 'normal' },
forExistingUsers: { type: 'boolean', default: false },
silence: { type: 'boolean', default: false },
needConfirmationToRead: { type: 'boolean', default: false },
Expand All @@ -80,24 +69,9 @@ export const paramDef = {
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
constructor(
@Inject(DI.announcementsRepository)
private announcementsRepository: AnnouncementsRepository,

private announcementService: AnnouncementService,
) {
super(meta, paramDef, async (ps, me) => {
const checkExisingEmergencyAnnouncement = async (): Promise<boolean> => {
const announcements = await this.announcementsRepository.findBy({
display: 'emergency',
isActive: true,
});
return announcements.length > 0;
};

if (ps.display === 'emergency' && await checkExisingEmergencyAnnouncement()) {
throw new ApiError(meta.errors.cannotMakeMoreEmergencyAnnouncement);
}

const { raw, packed } = await this.announcementService.create({
updatedAt: null,
title: ps.title,
Expand Down
Loading

1 comment on commit 4f39a4c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromatic detects changes. Please review the changes on Chromatic.

Please sign in to comment.