2023-01-12 21:40:33 -07: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";
|
2022-02-26 19:07:39 -07:00
|
|
|
// TODO
|
|
|
|
//const locales = await import('../../../../locales/index.js');
|
2021-02-12 20:28:26 -07:00
|
|
|
|
|
|
|
// TODO: locale ファイルをクライアント用とサーバー用で分けたい
|
|
|
|
|
2023-01-12 21:40:33 -07:00
|
|
|
async function follow(userId: User["id"], follower: User) {
|
2022-02-26 19:07:39 -07:00
|
|
|
/*
|
2022-03-26 00:34:00 -06:00
|
|
|
const userProfile = await UserProfiles.findOneByOrFail({ userId: userId });
|
2021-02-12 20:28:26 -07:00
|
|
|
if (!userProfile.email || !userProfile.emailNotificationTypes.includes('follow')) return;
|
|
|
|
const locale = locales[userProfile.lang || 'ja-JP'];
|
|
|
|
const i18n = new I18n(locale);
|
2021-07-15 05:35:43 -06:00
|
|
|
// TODO: render user information html
|
2021-11-11 10:02:25 -07:00
|
|
|
sendEmail(userProfile.email, i18n.t('_email._follow.title'), `${follower.name} (@${Acct.toString(follower)})`, `${follower.name} (@${Acct.toString(follower)})`);
|
2022-02-26 19:07:39 -07:00
|
|
|
*/
|
2021-02-12 20:28:26 -07:00
|
|
|
}
|
|
|
|
|
2023-01-12 21:40:33 -07:00
|
|
|
async function receiveFollowRequest(userId: User["id"], follower: User) {
|
2022-02-26 19:07:39 -07:00
|
|
|
/*
|
2022-03-26 00:34:00 -06:00
|
|
|
const userProfile = await UserProfiles.findOneByOrFail({ userId: userId });
|
2021-02-12 20:28:26 -07:00
|
|
|
if (!userProfile.email || !userProfile.emailNotificationTypes.includes('receiveFollowRequest')) return;
|
|
|
|
const locale = locales[userProfile.lang || 'ja-JP'];
|
|
|
|
const i18n = new I18n(locale);
|
2021-08-11 06:08:05 -06:00
|
|
|
// TODO: render user information html
|
2021-11-11 10:02:25 -07:00
|
|
|
sendEmail(userProfile.email, i18n.t('_email._receiveFollowRequest.title'), `${follower.name} (@${Acct.toString(follower)})`, `${follower.name} (@${Acct.toString(follower)})`);
|
2022-02-26 19:07:39 -07:00
|
|
|
*/
|
2021-02-12 20:28:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export const sendEmailNotification = {
|
|
|
|
follow,
|
|
|
|
receiveFollowRequest,
|
|
|
|
};
|