Skip to content

Commit

Permalink
Merge pull request misskey-dev#16 from nadesuki/nade_1.3.0
Browse files Browse the repository at this point in the history
Nadesskey 1.3.0
  • Loading branch information
tai-cha authored Sep 20, 2023
2 parents 6a89923 + b45dfb8 commit ae59fe7
Show file tree
Hide file tree
Showing 34 changed files with 498 additions and 9 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG_NADE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
オリジナルのMisskeyの変更履歴は(CHANGELOG)[CHANGELOG.md]をご覧ください。
オリジナルのMisskeyの変更履歴は[CHANGELOG](CHANGELOG.md)をご覧ください。

<!--
## Unlereased
Expand All @@ -8,6 +8,21 @@
### Server
-->
## nade 1.3.0

### General
[隠れ家様の実装を一部輸入させて頂きました(ちゃんとcherry-pick)](https://github.com/hideki0403/misskey.yukineko.me)
- feat: ファイル名をランダム化できるように
- 設定の「ドライブ」または「プライバシー」からONにできます。
- ONにすると、ファイルのアップロード時にファイル名がランダムな文字列になります。
- 新着ノート通知機能
- ユーザーがノートを投稿した際に通知を受け取れる機能
- ユーザーのプロフィールページのメニュー(・・・)にある「ノート通知を有効にする」から有効にできます。
- 設定→通知にある「ノート通知」から、自分が新着ノート通知を有効にしているユーザー一覧を見ることができます。

### Client
### Server

## nade 1.2.4
### General
### Client
Expand Down
1 change: 1 addition & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ cannotUploadBecauseInappropriate: "This file could not be uploaded because parts
cannotUploadBecauseNoFreeSpace: "Upload failed due to lack of Drive capacity."
cannotUploadBecauseExceedsFileSizeLimit: "This file cannot be uploaded as it exceeds the file size limit."
beta: "Beta"
originalFeature: "Nadesskey"
enableAutoSensitive: "Automatic marking as sensitive"
enableAutoSensitiveDescription: "Allows automatic detection and marking of sensitive media through Machine Learning where possible. Even if this option is disabled, it may be enabled instance-wide."
activeEmailValidationDescription: "Enables stricter validation of email addresses, which includes checking for disposable addresses and by whether it can actually be communicated with. When unchecked, only the format of the email is validated."
Expand Down
6 changes: 6 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,12 @@ export interface Locale {
"cannotUploadBecauseNoFreeSpace": string;
"cannotUploadBecauseExceedsFileSizeLimit": string;
"beta": string;
"originalFeature": string;
"enableAutoSensitive": string;
"enableAutoSensitiveDescription": string;
"activeEmailValidationDescription": string;
"filenameRandomize": string;
"filenameRandomizeDescription": string;
"navbar": string;
"shuffle": string;
"account": string;
Expand Down Expand Up @@ -1033,6 +1036,8 @@ export interface Locale {
"accountMovedShort": string;
"operationForbidden": string;
"forceShowAds": string;
"noteSubscribe": string;
"noteUnsubscribe": string;
"addMemo": string;
"editMemo": string;
"reactionsList": string;
Expand Down Expand Up @@ -2103,6 +2108,7 @@ export interface Locale {
"unreadAntennaNote": string;
"emptyPushNotificationMessage": string;
"achievementEarned": string;
"newNote": string;
"_types": {
"all": string;
"follow": string;
Expand Down
7 changes: 7 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -930,9 +930,12 @@ cannotUploadBecauseInappropriate: "不適切な内容を含む可能性がある
cannotUploadBecauseNoFreeSpace: "ドライブの空き容量が無いためアップロードできません。"
cannotUploadBecauseExceedsFileSizeLimit: "ファイルサイズの制限を超えているためアップロードできません。"
beta: "ベータ"
originalFeature: "Nadesskey"
enableAutoSensitive: "自動センシティブ判定"
enableAutoSensitiveDescription: "利用可能な場合は、機械学習を利用して自動でメディアにセンシティブフラグを設定します。この機能をオフにしても、サーバーによっては自動で設定されることがあります。"
activeEmailValidationDescription: "ユーザーのメールアドレスのバリデーションを、捨てアドかどうかや実際に通信可能かどうかなどを判定しより積極的に行います。オフにすると単に文字列として正しいかどうかのみチェックされます。"
filenameRandomize: "ファイル名をランダム化"
filenameRandomizeDescription: "ファイルのアップロード時にファイル名をランダムな文字列に変更します。以前にアップロードしたファイルのファイル名は変更されません。"
navbar: "ナビゲーションバー"
shuffle: "シャッフル"
account: "アカウント"
Expand Down Expand Up @@ -1030,6 +1033,8 @@ accountMoved: "このユーザーは新しいアカウントに移行しまし
accountMovedShort: "このアカウントは移行されています"
operationForbidden: "この操作はできません"
forceShowAds: "常に広告を表示する"
noteSubscribe: "ノート通知を有効にする"
noteUnsubscribe: "ノート通知を無効にする"
addMemo: "メモを追加"
editMemo: "メモを編集"
reactionsList: "リアクション一覧"
Expand Down Expand Up @@ -1116,6 +1121,7 @@ _initialAccountSetting:
_serverRules:
description: "新規登録前に表示する、サーバーの簡潔なルールを設定します。内容は利用規約の要約とすることを推奨します。"


_accountMigration:
moveFrom: "別のアカウントからこのアカウントに移行"
moveFromSub: "別のアカウントへエイリアスを作成"
Expand Down Expand Up @@ -2018,6 +2024,7 @@ _notification:
unreadAntennaNote: "アンテナ {name}"
emptyPushNotificationMessage: "プッシュ通知の更新をしました"
achievementEarned: "実績を獲得"
newNote: "{name}がノートしました"

_types:
all: "すべて"
Expand Down
1 change: 1 addition & 0 deletions locales/ja-KS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ cannotUploadBecauseInappropriate: "不適切な内容を含むかもしれへん
cannotUploadBecauseNoFreeSpace: "ドライブの空き容量が無いからアップロードできへんわ。"
cannotUploadBecauseExceedsFileSizeLimit: "ファイルが思うたよりも大きいさかいアップロードできへんでこれ。"
beta: "ベータ"
originalFeature: "Nadesskey"
enableAutoSensitive: "自動NSFW判定"
enableAutoSensitiveDescription: "使える時は、機械学習を使って自動でメディアにNSFWフラグを設定するで。この機能をオフにしても、サーバーによっては自動で設定されることがあるで。"
activeEmailValidationDescription: "ユーザーのメールアドレスのバリデーションを、捨てアドかどうかや実際に通信可能かどうかとかを判定して積極的に行うで。オフにすると単に文字列として正しいかどうかだけチェックするで。"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "13.14.2-nade1.2.4",
"version": "13.14.2-nade1.3.0",
"codename": "nasubi",
"repository": {
"type": "git",
Expand Down
Binary file added packages/backend/assets/tabler-badges/bell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions packages/backend/migration/1682932943132-note-notification.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/backend/src/core/CoreModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { NoteDeleteService } from './NoteDeleteService.js';
import { NotePiningService } from './NotePiningService.js';
import { NoteReadService } from './NoteReadService.js';
import { NotificationService } from './NotificationService.js';
import { NoteNotificationService } from './NoteNotificationService.js';
import { PollService } from './PollService.js';
import { PushNotificationService } from './PushNotificationService.js';
import { QueryService } from './QueryService.js';
Expand Down Expand Up @@ -152,6 +153,7 @@ const $NoteDeleteService: Provider = { provide: 'NoteDeleteService', useExisting
const $NotePiningService: Provider = { provide: 'NotePiningService', useExisting: NotePiningService };
const $NoteReadService: Provider = { provide: 'NoteReadService', useExisting: NoteReadService };
const $NotificationService: Provider = { provide: 'NotificationService', useExisting: NotificationService };
const $NoteNotificationService: Provider = { provide: 'NoteNotificationService', useExisting: NoteNotificationService };
const $PollService: Provider = { provide: 'PollService', useExisting: PollService };
const $ProxyAccountService: Provider = { provide: 'ProxyAccountService', useExisting: ProxyAccountService };
const $PushNotificationService: Provider = { provide: 'PushNotificationService', useExisting: PushNotificationService };
Expand Down Expand Up @@ -279,6 +281,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
NotePiningService,
NoteReadService,
NotificationService,
NoteNotificationService,
PollService,
ProxyAccountService,
PushNotificationService,
Expand Down Expand Up @@ -399,6 +402,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$NotePiningService,
$NoteReadService,
$NotificationService,
$NoteNotificationService,
$PollService,
$ProxyAccountService,
$PushNotificationService,
Expand Down Expand Up @@ -520,6 +524,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
NotePiningService,
NoteReadService,
NotificationService,
NoteNotificationService,
PollService,
ProxyAccountService,
PushNotificationService,
Expand Down Expand Up @@ -639,6 +644,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
$NotePiningService,
$NoteReadService,
$NotificationService,
$NoteNotificationService,
$PollService,
$ProxyAccountService,
$PushNotificationService,
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { NotificationService } from '@/core/NotificationService.js';
import { WebhookService } from '@/core/WebhookService.js';
import { HashtagService } from '@/core/HashtagService.js';
import { AntennaService } from '@/core/AntennaService.js';
import { NoteNotificationService } from '@/core/NoteNotificationService.js';
import { QueueService } from '@/core/QueueService.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
Expand All @@ -51,7 +52,7 @@ import { SearchService } from '@/core/SearchService.js';

const mutedWordsCache = new MemorySingleCache<{ userId: UserProfile['userId']; mutedWords: UserProfile['mutedWords']; }[]>(1000 * 60 * 5);

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

class NotificationManager {
private notifier: { id: User['id']; };
Expand Down Expand Up @@ -194,6 +195,7 @@ export class NoteCreateService implements OnApplicationShutdown {
private federatedInstanceService: FederatedInstanceService,
private hashtagService: HashtagService,
private antennaService: AntennaService,
private noteNotificationService: NoteNotificationService,
private webhookService: WebhookService,
private remoteUserResolveService: RemoteUserResolveService,
private apDeliverManagerService: ApDeliverManagerService,
Expand Down Expand Up @@ -498,6 +500,7 @@ export class NoteCreateService implements OnApplicationShutdown {
});

this.antennaService.addNoteToAntennas(note, user);
this.noteNotificationService.sendNotificationToSubscriber(note, user);

if (data.reply) {
this.saveReply(data.reply, note);
Expand Down
88 changes: 88 additions & 0 deletions packages/backend/src/core/NoteNotificationService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { Inject, Injectable } from '@nestjs/common';
import Redis from 'ioredis';
import type { NoteNotification } from '@/models/entities/NoteNotification.js';
import type { User } from '@/models/entities/User.js';
import type { Note } from '@/models/entities/Note.js';
import { IdService } from '@/core/IdService.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import { NotificationService } from '@/core/NotificationService.js';
import { PushNotificationService } from '@/core/PushNotificationService.js';
import { DI } from '@/di-symbols.js';
import type { NoteNotificationsRepository } from '@/models/index.js';
import { UtilityService } from '@/core/UtilityService.js';
import { bindThis } from '@/decorators.js';
import { StreamMessages } from '@/server/api/stream/types.js';
import type { OnApplicationShutdown } from '@nestjs/common';

@Injectable()
export class NoteNotificationService implements OnApplicationShutdown {
private targetUsersFetched: boolean;
private targetUsers: NoteNotification[];

constructor(
@Inject(DI.redisForSub)
private redisForSub: Redis.Redis,

@Inject(DI.noteNotificationsRepository)
private noteNotificationsRepository: NoteNotificationsRepository,

private notificationService: NotificationService,
) {
this.targetUsersFetched = false;
this.targetUsers = [];

this.redisForSub.on('message', this.onRedisMessage);
}

@bindThis
public onApplicationShutdown(signal?: string | undefined) {
this.redisForSub.off('message', this.onRedisMessage);
}

@bindThis
private async onRedisMessage(_: string, data: string): Promise<void> {
const obj = JSON.parse(data);

if (obj.channel === 'internal') {
const { type, body } = obj.message as StreamMessages['internal']['payload'];
switch (type) {
case 'noteNotificationCreated':
this.targetUsers.push({
...body,
createdAt: new Date(body.createdAt),
});
break;
case 'noteNotificationDeleted':
this.targetUsers = this.targetUsers.filter(a => a.id !== body.id);
break;
default:
break;
}
}
}

@bindThis
public async sendNotificationToSubscriber(note: Note, noteUser: { id: User['id']; username: string; host: string | null; }): Promise<void> {
if (!['public', 'home'].includes(note.visibility)) return;

const targetUsers = await this.getTargetUsers();
const matchedTargets = targetUsers.filter(x => x.targetUserId === noteUser.id);

matchedTargets.forEach(x => {
this.notificationService.createNotification(x.userId, 'note', {
notifierId: noteUser.id,
noteId: note.id,
});
});
}

@bindThis
public async getTargetUsers() {
if (!this.targetUsersFetched) {
this.targetUsers = await this.noteNotificationsRepository.find();
this.targetUsersFetched = true;
}

return this.targetUsers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { CustomEmojiService } from '../CustomEmojiService.js';
import type { UserEntityService } from './UserEntityService.js';
import type { NoteEntityService } from './NoteEntityService.js';

const NOTE_REQUIRED_NOTIFICATION_TYPES = new Set(['mention', 'reply', 'renote', 'quote', 'reaction', 'pollEnded'] as (typeof notificationTypes[number])[]);
const NOTE_REQUIRED_NOTIFICATION_TYPES = new Set(['mention', 'reply', 'renote', 'note', 'quote', 'reaction', 'pollEnded'] as (typeof notificationTypes[number])[]);

@Injectable()
export class NotificationEntityService implements OnModuleInit {
Expand Down
Loading

0 comments on commit ae59fe7

Please sign in to comment.