Compare commits
18 Commits
b18d7c0f3f
...
786677b079
Author | SHA1 | Date | |
---|---|---|---|
|
786677b079 | ||
|
68b90df00b | ||
|
7647aa637a | ||
|
de9b99c937 | ||
|
16847ba491 | ||
|
e781be3c72 | ||
|
e19193c9d0 | ||
|
5dc700938d | ||
|
93cf2f9045 | ||
|
c55af9c3b3 | ||
|
86a693b182 | ||
|
4e592fb1c9 | ||
|
5c1d16947c | ||
|
8897b191d9 | ||
|
652cc8602c | ||
|
6213018e62 | ||
|
808963189e | ||
|
5085c39440 |
@ -1306,6 +1306,7 @@ refreshing: "Refreshing..."
|
||||
pullDownToRefresh: "Pull down to refresh"
|
||||
disableStreamingTimeline: "Disable real-time timeline updates"
|
||||
useGroupedNotifications: "Display grouped notifications"
|
||||
allowClickingNotifications: "Allow clicking on pop-up notifications"
|
||||
signupPendingError: "There was a problem verifying the email address. The link may have expired."
|
||||
cwNotationRequired: "If \"Hide content\" is enabled, a description must be provided."
|
||||
doReaction: "Add reaction"
|
||||
|
4
locales/index.d.ts
vendored
4
locales/index.d.ts
vendored
@ -5237,6 +5237,10 @@ export interface Locale extends ILocale {
|
||||
* 通知をグルーピングして表示する
|
||||
*/
|
||||
"useGroupedNotifications": string;
|
||||
/**
|
||||
* ポップアップ通知のクリックを許可する
|
||||
*/
|
||||
"allowClickingNotifications": string;
|
||||
/**
|
||||
* メールアドレスの確認中に問題が発生しました。リンクの有効期限が切れている可能性があります。
|
||||
*/
|
||||
|
@ -1305,6 +1305,7 @@ refreshing: "リロード中"
|
||||
pullDownToRefresh: "引っ張ってリロード"
|
||||
disableStreamingTimeline: "タイムラインのリアルタイム更新を無効にする"
|
||||
useGroupedNotifications: "通知をグルーピングして表示する"
|
||||
allowClickingNotifications: "ポップアップ通知のクリックを許可する"
|
||||
signupPendingError: "メールアドレスの確認中に問題が発生しました。リンクの有効期限が切れている可能性があります。"
|
||||
cwNotationRequired: "「内容を隠す」がオンの場合は注釈の記述が必要です。"
|
||||
doReaction: "リアクションする"
|
||||
|
1
locales/version.d.ts
vendored
Normal file
1
locales/version.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export const localesVersion: string;
|
14
locales/version.js
Normal file
14
locales/version.js
Normal file
@ -0,0 +1,14 @@
|
||||
import { createHash } from 'crypto';
|
||||
import locales from './index.js';
|
||||
|
||||
// MD5 is acceptable because we don't need cryptographic security.
|
||||
const hash = createHash('md5');
|
||||
|
||||
// Derive the version hash from locale content exclusively.
|
||||
// This avoids the problem of "stuck" translations after modifying locale files.
|
||||
const localesText = JSON.stringify(locales);
|
||||
hash.update(localesText, 'utf8');
|
||||
|
||||
// We can't use regular base64 since this becomes part of a filename.
|
||||
// Base64URL avoids special characters that would cause an issue.
|
||||
export const localesVersion = hash.digest().toString('base64url');
|
@ -42,6 +42,7 @@ import { ModerationLogService } from './ModerationLogService.js';
|
||||
import { NoteCreateService } from './NoteCreateService.js';
|
||||
import { NoteEditService } from './NoteEditService.js';
|
||||
import { NoteDeleteService } from './NoteDeleteService.js';
|
||||
import { LatestNoteService } from './LatestNoteService.js';
|
||||
import { NotePiningService } from './NotePiningService.js';
|
||||
import { NoteReadService } from './NoteReadService.js';
|
||||
import { NotificationService } from './NotificationService.js';
|
||||
@ -185,6 +186,7 @@ const $ModerationLogService: Provider = { provide: 'ModerationLogService', useEx
|
||||
const $NoteCreateService: Provider = { provide: 'NoteCreateService', useExisting: NoteCreateService };
|
||||
const $NoteEditService: Provider = { provide: 'NoteEditService', useExisting: NoteEditService };
|
||||
const $NoteDeleteService: Provider = { provide: 'NoteDeleteService', useExisting: NoteDeleteService };
|
||||
const $LatestNoteService: Provider = { provide: 'LatestNoteService', useExisting: LatestNoteService };
|
||||
const $NotePiningService: Provider = { provide: 'NotePiningService', useExisting: NotePiningService };
|
||||
const $NoteReadService: Provider = { provide: 'NoteReadService', useExisting: NoteReadService };
|
||||
const $NotificationService: Provider = { provide: 'NotificationService', useExisting: NotificationService };
|
||||
@ -335,6 +337,7 @@ const $SponsorsService: Provider = { provide: 'SponsorsService', useExisting: Sp
|
||||
NoteCreateService,
|
||||
NoteEditService,
|
||||
NoteDeleteService,
|
||||
LatestNoteService,
|
||||
NotePiningService,
|
||||
NoteReadService,
|
||||
NotificationService,
|
||||
@ -481,6 +484,7 @@ const $SponsorsService: Provider = { provide: 'SponsorsService', useExisting: Sp
|
||||
$NoteCreateService,
|
||||
$NoteEditService,
|
||||
$NoteDeleteService,
|
||||
$LatestNoteService,
|
||||
$NotePiningService,
|
||||
$NoteReadService,
|
||||
$NotificationService,
|
||||
@ -628,6 +632,7 @@ const $SponsorsService: Provider = { provide: 'SponsorsService', useExisting: Sp
|
||||
NoteCreateService,
|
||||
NoteEditService,
|
||||
NoteDeleteService,
|
||||
LatestNoteService,
|
||||
NotePiningService,
|
||||
NoteReadService,
|
||||
NotificationService,
|
||||
@ -773,6 +778,7 @@ const $SponsorsService: Provider = { provide: 'SponsorsService', useExisting: Sp
|
||||
$NoteCreateService,
|
||||
$NoteEditService,
|
||||
$NoteDeleteService,
|
||||
$LatestNoteService,
|
||||
$NotePiningService,
|
||||
$NoteReadService,
|
||||
$NotificationService,
|
||||
|
139
packages/backend/src/core/LatestNoteService.ts
Normal file
139
packages/backend/src/core/LatestNoteService.ts
Normal file
@ -0,0 +1,139 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Not } from 'typeorm';
|
||||
import { MiNote } from '@/models/Note.js';
|
||||
import { isPureRenote } from '@/misc/is-renote.js';
|
||||
import { SkLatestNote } from '@/models/LatestNote.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { LatestNotesRepository, NotesRepository } from '@/models/_.js';
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import Logger from '@/logger.js';
|
||||
|
||||
@Injectable()
|
||||
export class LatestNoteService {
|
||||
private readonly logger: Logger;
|
||||
|
||||
constructor(
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
@Inject(DI.latestNotesRepository)
|
||||
private latestNotesRepository: LatestNotesRepository,
|
||||
|
||||
loggerService: LoggerService,
|
||||
) {
|
||||
this.logger = loggerService.getLogger('LatestNoteService');
|
||||
}
|
||||
|
||||
handleUpdatedNoteBG(before: MiNote, after: MiNote): void {
|
||||
this
|
||||
.handleUpdatedNote(before, after)
|
||||
.catch(err => this.logger.error('Unhandled exception while updating latest_note (after update):', err));
|
||||
}
|
||||
|
||||
async handleUpdatedNote(before: MiNote, after: MiNote): Promise<void> {
|
||||
// If the key didn't change, then there's nothing to update
|
||||
if (SkLatestNote.areEquivalent(before, after)) return;
|
||||
|
||||
// Simulate update as delete + create
|
||||
await this.handleDeletedNote(before);
|
||||
await this.handleCreatedNote(after);
|
||||
}
|
||||
|
||||
handleCreatedNoteBG(note: MiNote): void {
|
||||
this
|
||||
.handleCreatedNote(note)
|
||||
.catch(err => this.logger.error('Unhandled exception while updating latest_note (after create):', err));
|
||||
}
|
||||
|
||||
async handleCreatedNote(note: MiNote): Promise<void> {
|
||||
// Ignore DMs.
|
||||
// Followers-only posts are *included*, as this table is used to back the "following" feed.
|
||||
if (note.visibility === 'specified') return;
|
||||
|
||||
// Ignore pure renotes
|
||||
if (isPureRenote(note)) return;
|
||||
|
||||
// Compute the compound key of the entry to check
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
|
||||
// Make sure that this isn't an *older* post.
|
||||
// We can get older posts through replies, lookups, updates, etc.
|
||||
const currentLatest = await this.latestNotesRepository.findOneBy(key);
|
||||
if (currentLatest != null && currentLatest.noteId >= note.id) return;
|
||||
|
||||
// Record this as the latest note for the given user
|
||||
const latestNote = new SkLatestNote({
|
||||
...key,
|
||||
noteId: note.id,
|
||||
});
|
||||
await this.latestNotesRepository.upsert(latestNote, ['userId', 'isPublic', 'isReply', 'isQuote']);
|
||||
}
|
||||
|
||||
handleDeletedNoteBG(note: MiNote): void {
|
||||
this
|
||||
.handleDeletedNote(note)
|
||||
.catch(err => this.logger.error('Unhandled exception while updating latest_note (after delete):', err));
|
||||
}
|
||||
|
||||
async handleDeletedNote(note: MiNote): Promise<void> {
|
||||
// If it's a DM, then it can't possibly be the latest note so we can safely skip this.
|
||||
if (note.visibility === 'specified') return;
|
||||
|
||||
// If it's a pure renote, then it can't possibly be the latest note so we can safely skip this.
|
||||
if (isPureRenote(note)) return;
|
||||
|
||||
// Compute the compound key of the entry to check
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
|
||||
// Check if the deleted note was possibly the latest for the user
|
||||
const existingLatest = await this.latestNotesRepository.findOneBy(key);
|
||||
if (existingLatest == null || existingLatest.noteId !== note.id) return;
|
||||
|
||||
// Find the newest remaining note for the user.
|
||||
// We exclude DMs and pure renotes.
|
||||
const nextLatest = await this.notesRepository
|
||||
.createQueryBuilder('note')
|
||||
.select()
|
||||
.where({
|
||||
userId: key.userId,
|
||||
visibility: key.isPublic
|
||||
? 'public'
|
||||
: Not('specified'),
|
||||
replyId: key.isReply
|
||||
? Not(null)
|
||||
: null,
|
||||
renoteId: key.isQuote
|
||||
? Not(null)
|
||||
: null,
|
||||
})
|
||||
.andWhere(`
|
||||
(
|
||||
note."renoteId" IS NULL
|
||||
OR note.text IS NOT NULL
|
||||
OR note.cw IS NOT NULL
|
||||
OR note."replyId" IS NOT NULL
|
||||
OR note."hasPoll"
|
||||
OR note."fileIds" != '{}'
|
||||
)
|
||||
`)
|
||||
.orderBy({ id: 'DESC' })
|
||||
.getOne();
|
||||
if (!nextLatest) return;
|
||||
|
||||
// Record it as the latest
|
||||
const latestNote = new SkLatestNote({
|
||||
...key,
|
||||
noteId: nextLatest.id,
|
||||
});
|
||||
|
||||
// When inserting the latest note, it's possible that another worker has "raced" the insert and already added a newer note.
|
||||
// We must use orIgnore() to ensure that the query ignores conflicts, otherwise an exception may be thrown.
|
||||
await this.latestNotesRepository
|
||||
.createQueryBuilder('latest')
|
||||
.insert()
|
||||
.into(SkLatestNote)
|
||||
.values(latestNote)
|
||||
.orIgnore()
|
||||
.execute();
|
||||
}
|
||||
}
|
@ -14,8 +14,7 @@ import { extractCustomEmojisFromMfm } from '@/misc/extract-custom-emojis-from-mf
|
||||
import { extractHashtags } from '@/misc/extract-hashtags.js';
|
||||
import type { IMentionedRemoteUsers } from '@/models/Note.js';
|
||||
import { MiNote } from '@/models/Note.js';
|
||||
import { SkLatestNote } from '@/models/LatestNote.js';
|
||||
import type { ChannelFollowingsRepository, ChannelsRepository, FollowingsRepository, InstancesRepository, LatestNotesRepository, MiFollowing, MutingsRepository, NotesRepository, NoteThreadMutingsRepository, UserListMembershipsRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { ChannelFollowingsRepository, ChannelsRepository, FollowingsRepository, InstancesRepository, MiFollowing, MutingsRepository, NotesRepository, NoteThreadMutingsRepository, UserListMembershipsRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { MiDriveFile } from '@/models/DriveFile.js';
|
||||
import type { MiApp } from '@/models/App.js';
|
||||
import { concat } from '@/misc/prelude/array.js';
|
||||
@ -63,7 +62,7 @@ import { isReply } from '@/misc/is-reply.js';
|
||||
import { trackPromise } from '@/misc/promise-tracker.js';
|
||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { isPureRenote } from '@/misc/is-renote.js';
|
||||
import { LatestNoteService } from '@/core/LatestNoteService.js';
|
||||
|
||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
|
||||
|
||||
@ -172,9 +171,6 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
@Inject(DI.latestNotesRepository)
|
||||
private latestNotesRepository: LatestNotesRepository,
|
||||
|
||||
@Inject(DI.mutingsRepository)
|
||||
private mutingsRepository: MutingsRepository,
|
||||
|
||||
@ -226,6 +222,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||
private utilityService: UtilityService,
|
||||
private userBlockingService: UserBlockingService,
|
||||
private cacheService: CacheService,
|
||||
private latestNoteService: LatestNoteService,
|
||||
) { }
|
||||
|
||||
@bindThis
|
||||
@ -531,8 +528,6 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||
await this.notesRepository.insert(insert);
|
||||
}
|
||||
|
||||
await this.updateLatestNote(insert);
|
||||
|
||||
return insert;
|
||||
} catch (e) {
|
||||
// duplicate key error
|
||||
@ -815,6 +810,9 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||
});
|
||||
}
|
||||
|
||||
// Update the Latest Note index / following feed
|
||||
this.latestNoteService.handleCreatedNoteBG(note);
|
||||
|
||||
// Register to search database
|
||||
if (!user.noindex) this.index(note);
|
||||
}
|
||||
@ -1144,28 +1142,4 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||
public onApplicationShutdown(signal?: string | undefined): void {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
private async updateLatestNote(note: MiNote) {
|
||||
// Ignore DMs.
|
||||
// Followers-only posts are *included*, as this table is used to back the "following" feed.
|
||||
if (note.visibility === 'specified') return;
|
||||
|
||||
// Ignore pure renotes
|
||||
if (isPureRenote(note)) return;
|
||||
|
||||
// Compute the compound key of the entry to check
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
|
||||
// Make sure that this isn't an *older* post.
|
||||
// We can get older posts through replies, lookups, etc.
|
||||
const currentLatest = await this.latestNotesRepository.findOneBy(key);
|
||||
if (currentLatest != null && currentLatest.noteId >= note.id) return;
|
||||
|
||||
// Record this as the latest note for the given user
|
||||
const latestNote = new SkLatestNote({
|
||||
...key,
|
||||
noteId: note.id,
|
||||
});
|
||||
await this.latestNotesRepository.upsert(latestNote, ['userId', 'isPublic', 'isReply', 'isQuote']);
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,11 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Brackets, In, Not } from 'typeorm';
|
||||
import { Brackets, In } from 'typeorm';
|
||||
import { Injectable, Inject } from '@nestjs/common';
|
||||
import type { MiUser, MiLocalUser, MiRemoteUser } from '@/models/User.js';
|
||||
import { MiNote, IMentionedRemoteUsers } from '@/models/Note.js';
|
||||
import { SkLatestNote } from '@/models/LatestNote.js';
|
||||
import type { InstancesRepository, LatestNotesRepository, NotesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type { InstancesRepository, NotesRepository, UsersRepository } from '@/models/_.js';
|
||||
import { RelayService } from '@/core/RelayService.js';
|
||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
@ -20,12 +19,12 @@ import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||
import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { SearchService } from '@/core/SearchService.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
import { isPureRenote, isQuote, isRenote } from '@/misc/is-renote.js';
|
||||
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||
import { LatestNoteService } from '@/core/LatestNoteService.js';
|
||||
|
||||
@Injectable()
|
||||
export class NoteDeleteService {
|
||||
@ -39,14 +38,10 @@ export class NoteDeleteService {
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
@Inject(DI.latestNotesRepository)
|
||||
private latestNotesRepository: LatestNotesRepository,
|
||||
|
||||
@Inject(DI.instancesRepository)
|
||||
private instancesRepository: InstancesRepository,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private noteEntityService: NoteEntityService,
|
||||
private globalEventService: GlobalEventService,
|
||||
private relayService: RelayService,
|
||||
private federatedInstanceService: FederatedInstanceService,
|
||||
@ -58,6 +53,7 @@ export class NoteDeleteService {
|
||||
private notesChart: NotesChart,
|
||||
private perUserNotesChart: PerUserNotesChart,
|
||||
private instanceChart: InstanceChart,
|
||||
private latestNoteService: LatestNoteService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@ -152,7 +148,7 @@ export class NoteDeleteService {
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
await this.updateLatestNote(note);
|
||||
this.latestNoteService.handleDeletedNoteBG(note);
|
||||
|
||||
if (deleter && (note.userId !== deleter.id)) {
|
||||
const user = await this.usersRepository.findOneByOrFail({ id: note.userId });
|
||||
@ -235,66 +231,4 @@ export class NoteDeleteService {
|
||||
this.apDeliverManagerService.deliverToUser(user, content, remoteUser);
|
||||
}
|
||||
}
|
||||
|
||||
private async updateLatestNote(note: MiNote) {
|
||||
// If it's a DM, then it can't possibly be the latest note so we can safely skip this.
|
||||
if (note.visibility === 'specified') return;
|
||||
|
||||
// If it's a pure renote, then it can't possibly be the latest note so we can safely skip this.
|
||||
if (isPureRenote(note)) return;
|
||||
|
||||
// Compute the compound key of the entry to check
|
||||
const key = SkLatestNote.keyFor(note);
|
||||
|
||||
// Check if the deleted note was possibly the latest for the user
|
||||
const hasLatestNote = await this.latestNotesRepository.existsBy(key);
|
||||
if (hasLatestNote) return;
|
||||
|
||||
// Find the newest remaining note for the user.
|
||||
// We exclude DMs and pure renotes.
|
||||
const nextLatest = await this.notesRepository
|
||||
.createQueryBuilder('note')
|
||||
.select()
|
||||
.where({
|
||||
userId: key.userId,
|
||||
visibility: key.isPublic
|
||||
? 'public'
|
||||
: Not('specified'),
|
||||
replyId: key.isReply
|
||||
? Not(null)
|
||||
: null,
|
||||
renoteId: key.isQuote
|
||||
? Not(null)
|
||||
: null,
|
||||
})
|
||||
.andWhere(`
|
||||
(
|
||||
note."renoteId" IS NULL
|
||||
OR note.text IS NOT NULL
|
||||
OR note.cw IS NOT NULL
|
||||
OR note."replyId" IS NOT NULL
|
||||
OR note."hasPoll"
|
||||
OR note."fileIds" != '{}'
|
||||
)
|
||||
`)
|
||||
.orderBy({ id: 'DESC' })
|
||||
.getOne();
|
||||
if (!nextLatest) return;
|
||||
|
||||
// Record it as the latest
|
||||
const latestNote = new SkLatestNote({
|
||||
...key,
|
||||
noteId: nextLatest.id,
|
||||
});
|
||||
|
||||
// When inserting the latest note, it's possible that another worker has "raced" the insert and already added a newer note.
|
||||
// We must use orIgnore() to ensure that the query ignores conflicts, otherwise an exception may be thrown.
|
||||
await this.latestNotesRepository
|
||||
.createQueryBuilder('latest')
|
||||
.insert()
|
||||
.into(SkLatestNote)
|
||||
.values(latestNote)
|
||||
.orIgnore()
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ import { isReply } from '@/misc/is-reply.js';
|
||||
import { trackPromise } from '@/misc/promise-tracker.js';
|
||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||
import { LatestNoteService } from '@/core/LatestNoteService.js';
|
||||
|
||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention' | 'edited';
|
||||
|
||||
@ -214,6 +215,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||
private utilityService: UtilityService,
|
||||
private userBlockingService: UserBlockingService,
|
||||
private cacheService: CacheService,
|
||||
private latestNoteService: LatestNoteService,
|
||||
) { }
|
||||
|
||||
@bindThis
|
||||
@ -558,7 +560,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||
}
|
||||
|
||||
setImmediate('post edited', { signal: this.#shutdownController.signal }).then(
|
||||
() => this.postNoteEdited(note, user, data, silent, tags!, mentionedUsers!),
|
||||
() => this.postNoteEdited(note, oldnote, user, data, silent, tags!, mentionedUsers!),
|
||||
() => { /* aborted, ignore this */ },
|
||||
);
|
||||
|
||||
@ -569,7 +571,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private async postNoteEdited(note: MiNote, user: {
|
||||
private async postNoteEdited(note: MiNote, oldNote: MiNote, user: {
|
||||
id: MiUser['id'];
|
||||
username: MiUser['username'];
|
||||
host: MiUser['host'];
|
||||
@ -766,6 +768,9 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||
});
|
||||
}
|
||||
|
||||
// Update the Latest Note index / following feed
|
||||
this.latestNoteService.handleUpdatedNoteBG(oldNote, note);
|
||||
|
||||
// Register to search database
|
||||
if (!user.noindex) this.index(note);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ export class ApDbResolverService implements OnApplicationShutdown {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public parseUri(value: string | IObject): UriParseResult {
|
||||
public parseUri(value: string | IObject | [string | IObject]): UriParseResult {
|
||||
const separator = '/';
|
||||
|
||||
const uri = new URL(getApId(value));
|
||||
@ -78,7 +78,7 @@ export class ApDbResolverService implements OnApplicationShutdown {
|
||||
* AP Note => Misskey Note in DB
|
||||
*/
|
||||
@bindThis
|
||||
public async getNoteFromApId(value: string | IObject): Promise<MiNote | null> {
|
||||
public async getNoteFromApId(value: string | IObject | [string | IObject]): Promise<MiNote | null> {
|
||||
const parsed = this.parseUri(value);
|
||||
|
||||
if (parsed.local) {
|
||||
@ -98,7 +98,7 @@ export class ApDbResolverService implements OnApplicationShutdown {
|
||||
* AP Person => Misskey User in DB
|
||||
*/
|
||||
@bindThis
|
||||
public async getUserFromApId(value: string | IObject): Promise<MiLocalUser | MiRemoteUser | null> {
|
||||
public async getUserFromApId(value: string | IObject | [string | IObject]): Promise<MiLocalUser | MiRemoteUser | null> {
|
||||
const parsed = this.parseUri(value);
|
||||
|
||||
if (parsed.local) {
|
||||
|
@ -41,6 +41,7 @@ import { ApPersonService } from './models/ApPersonService.js';
|
||||
import { ApQuestionService } from './models/ApQuestionService.js';
|
||||
import type { Resolver } from './ApResolverService.js';
|
||||
import type { IAccept, IAdd, IAnnounce, IBlock, ICreate, IDelete, IFlag, IFollow, ILike, IObject, IReject, IRemove, IUndo, IUpdate, IMove, IPost } from './type.js';
|
||||
import { fromTuple } from '@/misc/from-tuple.js';
|
||||
|
||||
@Injectable()
|
||||
export class ApInboxService {
|
||||
@ -253,7 +254,8 @@ export class ApInboxService {
|
||||
}
|
||||
|
||||
if (activity.target === actor.featured) {
|
||||
const note = await this.apNoteService.resolveNote(activity.object);
|
||||
const object = fromTuple(activity.object);
|
||||
const note = await this.apNoteService.resolveNote(object);
|
||||
if (note == null) return 'note not found';
|
||||
await this.notePiningService.addPinned(actor, note.id);
|
||||
return;
|
||||
@ -270,11 +272,12 @@ export class ApInboxService {
|
||||
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
|
||||
if (!activity.object) return 'skip: activity has no object property';
|
||||
const targetUri = getApId(activity.object);
|
||||
const activityObject = fromTuple(activity.object);
|
||||
if (!activityObject) return 'skip: activity has no object property';
|
||||
const targetUri = getApId(activityObject);
|
||||
if (targetUri.startsWith('bear:')) return 'skip: bearcaps url not supported.';
|
||||
|
||||
const target = await resolver.resolve(activity.object).catch(e => {
|
||||
const target = await resolver.resolve(activityObject).catch(e => {
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
return e;
|
||||
});
|
||||
@ -370,29 +373,30 @@ export class ApInboxService {
|
||||
|
||||
this.logger.info(`Create: ${uri}`);
|
||||
|
||||
if (!activity.object) return 'skip: activity has no object property';
|
||||
const targetUri = getApId(activity.object);
|
||||
const activityObject = fromTuple(activity.object);
|
||||
if (!activityObject) return 'skip: activity has no object property';
|
||||
const targetUri = getApId(activityObject);
|
||||
if (targetUri.startsWith('bear:')) return 'skip: bearcaps url not supported.';
|
||||
|
||||
// copy audiences between activity <=> object.
|
||||
if (typeof activity.object === 'object') {
|
||||
const to = unique(concat([toArray(activity.to), toArray(activity.object.to)]));
|
||||
const cc = unique(concat([toArray(activity.cc), toArray(activity.object.cc)]));
|
||||
if (typeof activityObject === 'object') {
|
||||
const to = unique(concat([toArray(activity.to), toArray(activityObject.to)]));
|
||||
const cc = unique(concat([toArray(activity.cc), toArray(activityObject.cc)]));
|
||||
|
||||
activity.to = to;
|
||||
activity.cc = cc;
|
||||
activity.object.to = to;
|
||||
activity.object.cc = cc;
|
||||
activityObject.to = to;
|
||||
activityObject.cc = cc;
|
||||
}
|
||||
|
||||
// If there is no attributedTo, use Activity actor.
|
||||
if (typeof activity.object === 'object' && !activity.object.attributedTo) {
|
||||
activity.object.attributedTo = activity.actor;
|
||||
if (typeof activityObject === 'object' && !activityObject.attributedTo) {
|
||||
activityObject.attributedTo = activity.actor;
|
||||
}
|
||||
|
||||
const resolver = this.apResolverService.createResolver();
|
||||
|
||||
const object = await resolver.resolve(activity.object).catch(e => {
|
||||
const object = await resolver.resolve(activityObject).catch(e => {
|
||||
this.logger.error(`Resolution failed: ${e}`);
|
||||
throw e;
|
||||
});
|
||||
@ -448,15 +452,15 @@ export class ApInboxService {
|
||||
// 削除対象objectのtype
|
||||
let formerType: string | undefined;
|
||||
|
||||
if (typeof activity.object === 'string') {
|
||||
const activityObject = fromTuple(activity.object);
|
||||
if (typeof activityObject === 'string') {
|
||||
// typeが不明だけど、どうせ消えてるのでremote resolveしない
|
||||
formerType = undefined;
|
||||
} else {
|
||||
const object = activity.object;
|
||||
if (isTombstone(object)) {
|
||||
formerType = toSingle(object.formerType);
|
||||
if (isTombstone(activityObject)) {
|
||||
formerType = toSingle(activityObject.formerType);
|
||||
} else {
|
||||
formerType = toSingle(object.type);
|
||||
formerType = toSingle(activityObject.type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,7 +620,8 @@ export class ApInboxService {
|
||||
}
|
||||
|
||||
if (activity.target === actor.featured) {
|
||||
const note = await this.apNoteService.resolveNote(activity.object);
|
||||
const activityObject = fromTuple(activity.object);
|
||||
const note = await this.apNoteService.resolveNote(activityObject);
|
||||
if (note == null) return 'note not found';
|
||||
await this.notePiningService.removePinned(actor, note.id);
|
||||
return;
|
||||
|
@ -199,7 +199,8 @@ export class ApRendererService {
|
||||
type: 'Flag',
|
||||
actor: this.userEntityService.genLocalUserUri(user.id),
|
||||
content,
|
||||
object,
|
||||
// This MUST be an array for Pleroma compatibility: https://activitypub.software/TransFem-org/Sharkey/-/issues/641#note_7301
|
||||
object: [object],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ import { ApDbResolverService } from './ApDbResolverService.js';
|
||||
import { ApRendererService } from './ApRendererService.js';
|
||||
import { ApRequestService } from './ApRequestService.js';
|
||||
import type { IObject, ICollection, IOrderedCollection } from './type.js';
|
||||
import { fromTuple } from '@/misc/from-tuple.js';
|
||||
|
||||
export class Resolver {
|
||||
private history: Set<string>;
|
||||
@ -67,7 +68,10 @@ export class Resolver {
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async resolve(value: string | IObject): Promise<IObject> {
|
||||
public async resolve(value: string | IObject | [string | IObject]): Promise<IObject> {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
value = fromTuple(value);
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
return value;
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { fromTuple } from '@/misc/from-tuple.js';
|
||||
|
||||
export type Obj = { [x: string]: any };
|
||||
export type ApObject = IObject | string | (IObject | string)[];
|
||||
|
||||
@ -52,10 +54,13 @@ export function getOneApId(value: ApObject): string {
|
||||
/**
|
||||
* Get ActivityStreams Object id
|
||||
*/
|
||||
export function getApId(value: string | IObject): string {
|
||||
export function getApId(value: string | IObject | [string | IObject]): string {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
value = fromTuple(value);
|
||||
|
||||
if (typeof value === 'string') return value;
|
||||
if (typeof value.id === 'string') return value.id;
|
||||
throw new Error('cannot detemine id');
|
||||
throw new Error('cannot determine id');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +89,9 @@ export function getApHrefNullable(value: string | IObject | undefined): string |
|
||||
export interface IActivity extends IObject {
|
||||
//type: 'Activity';
|
||||
actor: IObject | string;
|
||||
object: IObject | string;
|
||||
// ActivityPub spec allows for arrays: https://www.w3.org/TR/activitystreams-vocabulary/#properties
|
||||
// Misskey can only handle one value, so we use a tuple for that case.
|
||||
object: IObject | string | [IObject | string] ;
|
||||
target?: IObject | string;
|
||||
/** LD-Signature */
|
||||
signature?: {
|
||||
|
7
packages/backend/src/misc/from-tuple.ts
Normal file
7
packages/backend/src/misc/from-tuple.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export function fromTuple<T>(value: T | [T]): T {
|
||||
if (Array.isArray(value)) {
|
||||
return value[0];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
@ -82,4 +82,19 @@ export class SkLatestNote {
|
||||
isQuote: isRenote(note) && isQuote(note),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if two notes would produce equivalent compound keys.
|
||||
*/
|
||||
static areEquivalent(first: MiNote, second: MiNote): boolean {
|
||||
const firstKey = SkLatestNote.keyFor(first);
|
||||
const secondKey = SkLatestNote.keyFor(second);
|
||||
|
||||
return (
|
||||
firstKey.userId === secondKey.userId &&
|
||||
firstKey.isPublic === secondKey.isPublic &&
|
||||
firstKey.isReply === secondKey.isReply &&
|
||||
firstKey.isQuote === secondKey.isQuote
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,17 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Force update when locales change
|
||||
const langsVersion = LANGS_VERSION;
|
||||
const localeVersion = localStorage.getItem('localeVersion');
|
||||
if (localeVersion !== langsVersion) {
|
||||
console.info(`Updating locales from version ${localeVersion ?? 'N/A'} to ${langsVersion}`);
|
||||
localStorage.removeItem('localeVersion');
|
||||
localStorage.removeItem('locale');
|
||||
}
|
||||
|
||||
//#region Detect language & fetch translations
|
||||
if (!localStorage.hasOwnProperty('locale')) {
|
||||
if (!localStorage.getItem('locale')) {
|
||||
const supportedLangs = LANGS;
|
||||
let lang = localStorage.getItem('lang');
|
||||
if (lang == null || !supportedLangs.includes(lang)) {
|
||||
@ -48,37 +57,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
const metaRes = await window.fetch('/api/meta', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({}),
|
||||
credentials: 'omit',
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
if (metaRes.status !== 200) {
|
||||
renderError('META_FETCH');
|
||||
return;
|
||||
}
|
||||
const meta = await metaRes.json();
|
||||
const v = meta.version;
|
||||
if (v == null) {
|
||||
renderError('META_FETCH_V');
|
||||
return;
|
||||
}
|
||||
|
||||
// for https://github.com/misskey-dev/misskey/issues/10202
|
||||
if (lang == null || lang.toString == null || lang.toString() === 'null') {
|
||||
console.error('invalid lang value detected!!!', typeof lang, lang);
|
||||
lang = 'en-US';
|
||||
}
|
||||
|
||||
const localRes = await window.fetch(`/assets/locales/${lang}.${v}.json`);
|
||||
const localRes = await window.fetch(`/assets/locales/${lang}.${langsVersion}.json`);
|
||||
if (localRes.status === 200) {
|
||||
localStorage.setItem('lang', lang);
|
||||
localStorage.setItem('locale', await localRes.text());
|
||||
localStorage.setItem('localeVersion', v);
|
||||
localStorage.setItem('localeVersion', langsVersion);
|
||||
} else {
|
||||
renderError('LOCALE_FETCH');
|
||||
return;
|
||||
|
13
packages/backend/test/unit/misc/from-tuple.ts
Normal file
13
packages/backend/test/unit/misc/from-tuple.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { fromTuple } from '@/misc/from-tuple.js';
|
||||
|
||||
describe(fromTuple, () => {
|
||||
it('should return value when value is not an array', () => {
|
||||
const value = fromTuple('abc');
|
||||
expect(value).toBe('abc');
|
||||
});
|
||||
|
||||
it('should return first element when value is an array', () => {
|
||||
const value = fromTuple(['abc']);
|
||||
expect(value).toBe('abc');
|
||||
});
|
||||
});
|
@ -63,4 +63,87 @@ describe(SkLatestNote, () => {
|
||||
expect(key.isQuote).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('areEquivalent', () => {
|
||||
it('should return true when keys match', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true when keys match with different reply IDs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: '3', renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: '4', renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true when keys match with different renote IDs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: '3', fileIds: ['1'] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: '4', fileIds: ['1'] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true when keys match with different file counts', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: ['1'] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: ['1','2'] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return true when keys match with different private visibilities', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'home', replyId: null, renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'followers', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false when user ID differs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'def456', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false when visibility differs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'home', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false when reply differs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: '1', renoteId: null, fileIds: [] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return false when quote differs', () => {
|
||||
const first = new MiNote({ id: '1', userId: 'abc123', visibility: 'public', replyId: null, renoteId: '3', fileIds: ['1'] });
|
||||
const second = new MiNote({ id: '2', userId: 'abc123', visibility: 'public', replyId: null, renoteId: null, fileIds: [] });
|
||||
|
||||
const result = SkLatestNote.areEquivalent(first, second);
|
||||
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
1
packages/frontend/@types/global.d.ts
vendored
1
packages/frontend/@types/global.d.ts
vendored
@ -6,6 +6,7 @@
|
||||
type FIXME = any;
|
||||
|
||||
declare const _LANGS_: string[][];
|
||||
declare const _LANGS_VERSION_: string;
|
||||
declare const _VERSION_: string;
|
||||
declare const _ENV_: string;
|
||||
declare const _DEV_: boolean;
|
||||
|
@ -8,7 +8,7 @@ import { compareVersions } from 'compare-versions';
|
||||
import widgets from '@/widgets/index.js';
|
||||
import directives from '@/directives/index.js';
|
||||
import components from '@/components/index.js';
|
||||
import { version, lang, updateLocale, locale } from '@/config.js';
|
||||
import { version, lang, langsVersion, updateLocale, locale } from '@/config.js';
|
||||
import { applyTheme } from '@/scripts/theme.js';
|
||||
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode.js';
|
||||
import { updateI18n } from '@/i18n.js';
|
||||
@ -80,14 +80,15 @@ export async function common(createVue: () => App<Element>) {
|
||||
|
||||
//#region Detect language & fetch translations
|
||||
const localeVersion = miLocalStorage.getItem('localeVersion');
|
||||
const localeOutdated = (localeVersion == null || localeVersion !== version || locale == null);
|
||||
const localeOutdated = (localeVersion == null || localeVersion !== langsVersion || locale == null);
|
||||
if (localeOutdated) {
|
||||
const res = await window.fetch(`/assets/locales/${lang}.${version}.json`);
|
||||
console.info(`Updating locales from version ${localeVersion ?? 'N/A'} to ${langsVersion}`);
|
||||
const res = await window.fetch(`/assets/locales/${lang}.${langsVersion}.json`);
|
||||
if (res.status === 200) {
|
||||
const newLocale = await res.text();
|
||||
const parsedNewLocale = JSON.parse(newLocale);
|
||||
miLocalStorage.setItem('locale', newLocale);
|
||||
miLocalStorage.setItem('localeVersion', version);
|
||||
miLocalStorage.setItem('localeVersion', langsVersion);
|
||||
updateLocale(parsedNewLocale);
|
||||
updateI18n(parsedNewLocale);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ export const apiUrl = location.origin + '/api';
|
||||
export const wsOrigin = location.origin;
|
||||
export const lang = miLocalStorage.getItem('lang') ?? 'en-US';
|
||||
export const langs = _LANGS_;
|
||||
export const langsVersion = _LANGS_VERSION_;
|
||||
const preParseLocale = miLocalStorage.getItem('locale');
|
||||
export let locale = preParseLocale ? JSON.parse(preParseLocale) : null;
|
||||
export const version = _VERSION_;
|
||||
|
@ -170,6 +170,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<option value="horizontal"><i class="ti ti-carousel-horizontal"></i> {{ i18n.ts.horizontal }}</option>
|
||||
</MkRadios>
|
||||
|
||||
<MkSwitch v-model="notificationClickable">{{ i18n.ts.allowClickingNotifications }}</MkSwitch>
|
||||
|
||||
<MkButton @click="testNotification">{{ i18n.ts._notification.checkNotificationBehavior }}</MkButton>
|
||||
</div>
|
||||
</FormSection>
|
||||
@ -411,6 +413,7 @@ const showAvatarDecorations = computed(defaultStore.makeGetterSetter('showAvatar
|
||||
const mediaListWithOneImageAppearance = computed(defaultStore.makeGetterSetter('mediaListWithOneImageAppearance'));
|
||||
const notificationPosition = computed(defaultStore.makeGetterSetter('notificationPosition'));
|
||||
const notificationStackAxis = computed(defaultStore.makeGetterSetter('notificationStackAxis'));
|
||||
const notificationClickable = computed(defaultStore.makeGetterSetter('notificationClickable'));
|
||||
const keepScreenOn = computed(defaultStore.makeGetterSetter('keepScreenOn'));
|
||||
const disableStreamingTimeline = computed(defaultStore.makeGetterSetter('disableStreamingTimeline'));
|
||||
const useGroupedNotifications = computed(defaultStore.makeGetterSetter('useGroupedNotifications'));
|
||||
|
@ -479,6 +479,10 @@ export const defaultStore = markRaw(new Storage('base', {
|
||||
where: 'device',
|
||||
default: 'horizontal' as 'vertical' | 'horizontal',
|
||||
},
|
||||
notificationClickable: {
|
||||
where: 'device',
|
||||
default: false,
|
||||
},
|
||||
enableCondensedLineForAcct: {
|
||||
where: 'device',
|
||||
default: false,
|
||||
|
@ -30,7 +30,11 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
:enterFromClass="defaultStore.state.animation ? $style.transition_notification_enterFrom : ''"
|
||||
:leaveToClass="defaultStore.state.animation ? $style.transition_notification_leaveTo : ''"
|
||||
>
|
||||
<div v-for="notification in notifications" :key="notification.id" :class="$style.notification">
|
||||
<div
|
||||
v-for="notification in notifications" :key="notification.id" :class="$style.notification" :style="{
|
||||
pointerEvents: getPointerEvents()
|
||||
}"
|
||||
>
|
||||
<XNotification :notification="notification"/>
|
||||
</div>
|
||||
</TransitionGroup>
|
||||
@ -101,6 +105,10 @@ if ($i) {
|
||||
swInject();
|
||||
}
|
||||
}
|
||||
|
||||
function getPointerEvents() {
|
||||
return defaultStore.state.notificationClickable ? undefined : 'none';
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
@ -122,7 +130,6 @@ if ($i) {
|
||||
position: fixed;
|
||||
z-index: 3900000;
|
||||
padding: 0 var(--margin);
|
||||
pointer-events: none;
|
||||
display: flex;
|
||||
|
||||
&.notificationsPosition_leftTop {
|
||||
|
@ -2,7 +2,7 @@ import path from 'path';
|
||||
import pluginReplace from '@rollup/plugin-replace';
|
||||
import pluginVue from '@vitejs/plugin-vue';
|
||||
import { type UserConfig, defineConfig } from 'vite';
|
||||
|
||||
import { localesVersion } from '../../locales/version.js';
|
||||
import locales from '../../locales/index.js';
|
||||
import meta from '../../package.json';
|
||||
import packageInfo from './package.json' with { type: 'json' };
|
||||
@ -110,6 +110,7 @@ export function getConfig(): UserConfig {
|
||||
define: {
|
||||
_VERSION_: JSON.stringify(meta.version),
|
||||
_LANGS_: JSON.stringify(Object.entries(locales).map(([k, v]) => [k, v._lang_])),
|
||||
_LANGS_VERSION_: JSON.stringify(localesVersion),
|
||||
_ENV_: JSON.stringify(process.env.NODE_ENV),
|
||||
_DEV_: process.env.NODE_ENV !== 'production',
|
||||
_PERF_PREFIX_: JSON.stringify('Misskey:'),
|
||||
|
@ -15,6 +15,7 @@ import { build as buildLocales } from '../locales/index.js';
|
||||
import generateDTS from '../locales/generateDTS.js';
|
||||
import meta from '../package.json' with { type: "json" };
|
||||
import buildTarball from './tarball.mjs';
|
||||
import { localesVersion } from '../locales/version.js';
|
||||
|
||||
const configDir = fileURLToPath(new URL('../.config', import.meta.url));
|
||||
const configPath = process.env.MISSKEY_CONFIG_YML
|
||||
@ -56,10 +57,10 @@ async function copyFrontendLocales() {
|
||||
|
||||
await fs.mkdir('./built/_frontend_dist_/locales', { recursive: true });
|
||||
|
||||
const v = { '_version_': meta.version };
|
||||
const v = { '_version_': localesVersion };
|
||||
|
||||
for (const [lang, locale] of Object.entries(locales)) {
|
||||
await fs.writeFile(`./built/_frontend_dist_/locales/${lang}.${meta.version}.json`, JSON.stringify({ ...locale, ...v }), 'utf-8');
|
||||
await fs.writeFile(`./built/_frontend_dist_/locales/${lang}.${localesVersion}.json`, JSON.stringify({ ...locale, ...v }), 'utf-8');
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +77,8 @@ async function buildBackendScript() {
|
||||
'./packages/backend/src/server/web/cli.js'
|
||||
]) {
|
||||
let source = await fs.readFile(file, { encoding: 'utf-8' });
|
||||
source = source.replaceAll('LANGS', JSON.stringify(Object.keys(locales)));
|
||||
source = source.replaceAll(/\bLANGS\b/g, JSON.stringify(Object.keys(locales)));
|
||||
source = source.replaceAll(/\bLANGS_VERSION\b/g, JSON.stringify(localesVersion));
|
||||
const { code } = await terser.minify(source, { toplevel: true });
|
||||
await fs.writeFile(`./packages/backend/built/server/web/${path.basename(file)}`, code);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user