fix: emojis not being populated for local users
This commit is contained in:
parent
d0af17c674
commit
7481ece433
@ -19,6 +19,7 @@ import { UtilityService } from '@/core/UtilityService.js';
|
|||||||
import { query } from '@/misc/prelude/url.js';
|
import { query } from '@/misc/prelude/url.js';
|
||||||
import type { Serialized } from '@/server/api/stream/types.js';
|
import type { Serialized } from '@/server/api/stream/types.js';
|
||||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
import type { Config } from '@/config.js';
|
||||||
|
|
||||||
const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/;
|
const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/;
|
||||||
|
|
||||||
@ -31,6 +32,9 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||||||
@Inject(DI.redis)
|
@Inject(DI.redis)
|
||||||
private redisClient: Redis.Redis,
|
private redisClient: Redis.Redis,
|
||||||
|
|
||||||
|
@Inject(DI.config)
|
||||||
|
private config: Config,
|
||||||
|
|
||||||
@Inject(DI.emojisRepository)
|
@Inject(DI.emojisRepository)
|
||||||
private emojisRepository: EmojisRepository,
|
private emojisRepository: EmojisRepository,
|
||||||
|
|
||||||
@ -330,9 +334,11 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||||||
if (name == null) return null;
|
if (name == null) return null;
|
||||||
if (host == null) return null;
|
if (host == null) return null;
|
||||||
|
|
||||||
|
const newHost = host === this.config.host ? null : host;
|
||||||
|
|
||||||
const queryOrNull = async () => (await this.emojisRepository.findOneBy({
|
const queryOrNull = async () => (await this.emojisRepository.findOneBy({
|
||||||
name,
|
name,
|
||||||
host: host ?? IsNull(),
|
host: newHost ?? IsNull(),
|
||||||
})) ?? null;
|
})) ?? null;
|
||||||
|
|
||||||
const emoji = await this.cache.fetch(`${name} ${host}`, queryOrNull);
|
const emoji = await this.cache.fetch(`${name} ${host}`, queryOrNull);
|
||||||
|
@ -22,6 +22,7 @@ import type { CustomEmojiService } from '../CustomEmojiService.js';
|
|||||||
import type { ReactionService } from '../ReactionService.js';
|
import type { ReactionService } from '../ReactionService.js';
|
||||||
import type { UserEntityService } from './UserEntityService.js';
|
import type { UserEntityService } from './UserEntityService.js';
|
||||||
import type { DriveFileEntityService } from './DriveFileEntityService.js';
|
import type { DriveFileEntityService } from './DriveFileEntityService.js';
|
||||||
|
import type { Config } from '@/config.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NoteEntityService implements OnModuleInit {
|
export class NoteEntityService implements OnModuleInit {
|
||||||
@ -36,6 +37,9 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
|
@Inject(DI.config)
|
||||||
|
private config: Config,
|
||||||
|
|
||||||
@Inject(DI.notesRepository)
|
@Inject(DI.notesRepository)
|
||||||
private notesRepository: NotesRepository,
|
private notesRepository: NotesRepository,
|
||||||
|
|
||||||
@ -286,7 +290,7 @@ export class NoteEntityService implements OnModuleInit {
|
|||||||
|
|
||||||
const meId = me ? me.id : null;
|
const meId = me ? me.id : null;
|
||||||
const note = typeof src === 'object' ? src : await this.notesRepository.findOneOrFail({ where: { id: src }, relations: ['user'] });
|
const note = typeof src === 'object' ? src : await this.notesRepository.findOneOrFail({ where: { id: src }, relations: ['user'] });
|
||||||
const host = note.userHost;
|
const host = note.userHost === null ? this.config.host : note.userHost;
|
||||||
|
|
||||||
let text = note.text;
|
let text = note.text;
|
||||||
|
|
||||||
|
@ -339,6 +339,8 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
|
|
||||||
const falsy = opts.detail ? false : undefined;
|
const falsy = opts.detail ? false : undefined;
|
||||||
|
|
||||||
|
const checkHost = user.host == null ? this.config.host : user.host;
|
||||||
|
|
||||||
const packed = {
|
const packed = {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
@ -361,7 +363,7 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
followersCount: followersCount ?? 0,
|
followersCount: followersCount ?? 0,
|
||||||
followingCount: followingCount ?? 0,
|
followingCount: followingCount ?? 0,
|
||||||
notesCount: user.notesCount,
|
notesCount: user.notesCount,
|
||||||
emojis: this.customEmojiService.populateEmojis(user.emojis, user.host),
|
emojis: this.customEmojiService.populateEmojis(user.emojis, checkHost),
|
||||||
onlineStatus: this.getOnlineStatus(user),
|
onlineStatus: this.getOnlineStatus(user),
|
||||||
// パフォーマンス上の理由でローカルユーザーのみ
|
// パフォーマンス上の理由でローカルユーザーのみ
|
||||||
badgeRoles: user.host == null ? this.roleService.getUserBadgeRoles(user.id).then(rs => rs.sort((a, b) => b.displayOrder - a.displayOrder).map(r => ({
|
badgeRoles: user.host == null ? this.roleService.getUserBadgeRoles(user.id).then(rs => rs.sort((a, b) => b.displayOrder - a.displayOrder).map(r => ({
|
||||||
|
Loading…
Reference in New Issue
Block a user