iceshrimp-161sh/packages/backend/src/services/send-email-notification.ts

37 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-01-13 05:40:33 +01:00
import { UserProfiles } from "@/models/index.js";
import type { User } from "@/models/entities/user.js";
import { sendEmail } from "./send-email.js";
import { I18n } from "@/misc/i18n.js";
import * as Acct from "@/misc/acct.js";
// TODO
//const locales = await import('../../../../locales/index.js');
2021-02-13 04:28:26 +01:00
// TODO: locale ファイルをクライアント用とサーバー用で分けたい
2023-01-13 05:40:33 +01:00
async function follow(userId: User["id"], follower: User) {
/*
const userProfile = await UserProfiles.findOneByOrFail({ userId: userId });
2021-02-13 04:28:26 +01:00
if (!userProfile.email || !userProfile.emailNotificationTypes.includes('follow')) return;
const locale = locales[userProfile.lang || 'ja-JP'];
const i18n = new I18n(locale);
2021-07-15 13:35:43 +02:00
// TODO: render user information html
2021-11-11 18:02:25 +01:00
sendEmail(userProfile.email, i18n.t('_email._follow.title'), `${follower.name} (@${Acct.toString(follower)})`, `${follower.name} (@${Acct.toString(follower)})`);
*/
2021-02-13 04:28:26 +01:00
}
2023-01-13 05:40:33 +01:00
async function receiveFollowRequest(userId: User["id"], follower: User) {
/*
const userProfile = await UserProfiles.findOneByOrFail({ userId: userId });
2021-02-13 04:28:26 +01:00
if (!userProfile.email || !userProfile.emailNotificationTypes.includes('receiveFollowRequest')) return;
const locale = locales[userProfile.lang || 'ja-JP'];
const i18n = new I18n(locale);
// TODO: render user information html
2021-11-11 18:02:25 +01:00
sendEmail(userProfile.email, i18n.t('_email._receiveFollowRequest.title'), `${follower.name} (@${Acct.toString(follower)})`, `${follower.name} (@${Acct.toString(follower)})`);
*/
2021-02-13 04:28:26 +01:00
}
export const sendEmailNotification = {
follow,
receiveFollowRequest,
};