2023-10-30 09:58:37 +01:00
|
|
|
// import { UserProfiles } from "@/models/index.js";
|
2023-01-13 05:40:33 +01:00
|
|
|
import type { User } from "@/models/entities/user.js";
|
2023-10-30 09:58:37 +01:00
|
|
|
// import { sendEmail } from "./send-email.js";
|
|
|
|
// import { I18n } from "@/misc/i18n.js";
|
2024-04-11 23:10:11 +02:00
|
|
|
// import { acctToString } from "backend-rs";
|
2022-02-27 03:07:39 +01:00
|
|
|
// 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) {
|
2022-02-27 03:07:39 +01:00
|
|
|
/*
|
2022-03-26 07:34:00 +01:00
|
|
|
const userProfile = await UserProfiles.findOneByOrFail({ userId: userId });
|
2021-02-13 04:28:26 +01:00
|
|
|
if (!userProfile.email || !userProfile.emailNotificationTypes.includes('follow')) return;
|
2024-02-20 19:25:45 +01:00
|
|
|
const locale = locales['en-US'];
|
2021-02-13 04:28:26 +01:00
|
|
|
const i18n = new I18n(locale);
|
2021-07-15 13:35:43 +02:00
|
|
|
// TODO: render user information html
|
2024-04-11 23:10:11 +02:00
|
|
|
sendEmail(userProfile.email, i18n.t('_email._follow.title'), `${follower.name} (@${acctToString(follower)})`, `${follower.name} (@${acctToString(follower)})`);
|
2022-02-27 03:07:39 +01:00
|
|
|
*/
|
2021-02-13 04:28:26 +01:00
|
|
|
}
|
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
async function receiveFollowRequest(userId: User["id"], follower: User) {
|
2022-02-27 03:07:39 +01:00
|
|
|
/*
|
2022-03-26 07:34:00 +01:00
|
|
|
const userProfile = await UserProfiles.findOneByOrFail({ userId: userId });
|
2021-02-13 04:28:26 +01:00
|
|
|
if (!userProfile.email || !userProfile.emailNotificationTypes.includes('receiveFollowRequest')) return;
|
2024-02-20 19:25:45 +01:00
|
|
|
const locale = locales['en-US'];
|
2021-02-13 04:28:26 +01:00
|
|
|
const i18n = new I18n(locale);
|
2021-08-11 14:08:05 +02:00
|
|
|
// TODO: render user information html
|
2024-04-11 23:10:11 +02:00
|
|
|
sendEmail(userProfile.email, i18n.t('_email._receiveFollowRequest.title'), `${follower.name} (@${acctToString(follower)})`, `${follower.name} (@${acctToString(follower)})`);
|
2022-02-27 03:07:39 +01:00
|
|
|
*/
|
2021-02-13 04:28:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const sendEmailNotification = {
|
|
|
|
follow,
|
|
|
|
receiveFollowRequest,
|
|
|
|
};
|