Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import {
} from '@teable/core';
import type { Prisma } from '@teable/db-main-prisma';
import { PrismaService } from '@teable/db-main-prisma';
import { MailTransporterType, MailType } from '@teable/openapi';
import {
MailTransporterType,
MailType,
type IGetNotifyListQuery,
type INotificationUnreadCountVo,
type INotificationVo,
Expand Down Expand Up @@ -48,12 +47,11 @@ export class NotificationService {
private readonly i18n: I18nService<I18nTranslations>
) {}

private async getUserLang(userId: string) {
const user = await this.userService.getUserById(userId);
return user?.lang ?? I18nContext.current()?.lang;
getUserLang(lang?: string | null) {
return lang ?? I18nContext.current()?.lang;
}

private getMessage(text: string | ILocalization<I18nPath>, lang?: string) {
getMessage(text: string | ILocalization<I18nPath>, lang?: string) {
return typeof text === 'string'
? text
: (this.i18n.t(text.i18nKey, {
Expand All @@ -65,7 +63,7 @@ export class NotificationService {
/**
* notification message i18n use common prefix, so we need to remove it to save db
*/
private getMessageI18n(localization: string | ILocalization<I18nPath>) {
getMessageI18n(localization: string | ILocalization<I18nPath>) {
return typeof localization === 'string'
? undefined
: JSON.stringify({
Expand Down Expand Up @@ -251,7 +249,7 @@ export class NotificationService {
this.sendNotifyBySocket(toUser.id, socketNotification);

if (emailConfig && toUser.notifyMeta && toUser.notifyMeta.email) {
const lang = await this.getUserLang(toUserId);
const lang = this.getUserLang(toUser.lang);
const emailOptions = await this.mailSenderService.htmlEmailOptions({
...emailConfig,
title: this.getMessage(emailConfig.title, lang),
Expand Down Expand Up @@ -340,7 +338,7 @@ export class NotificationService {
this.sendNotifyBySocket(toUser.id, socketNotification);

if (emailConfig && toUser.notifyMeta && toUser.notifyMeta.email) {
const lang = await this.getUserLang(toUserId);
const lang = this.getUserLang(toUser.lang);
const emailOptions = await this.mailSenderService.commonEmailOptions({
...emailConfig,
title: this.getMessage(emailConfig.title, lang),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class SettingOpenApiController {
SettingKey.AI_CONFIG,
SettingKey.APP_CONFIG,
SettingKey.WEB_SEARCH_CONFIG,
SettingKey.ENABLE_CREDIT_REWARD,
]);
const { aiConfig, appConfig, webSearchConfig, ...rest } = setting;
return {
Expand Down
Loading