fix email bug
This commit is contained in:
@@ -132,7 +132,6 @@ export async function sendMentionEmail(opts: {
|
|||||||
message: string;
|
message: string;
|
||||||
dashboardUrl: string;
|
dashboardUrl: string;
|
||||||
}) {
|
}) {
|
||||||
if (await isDemoMode()) return;
|
|
||||||
const { to, parentName, authorName, message, dashboardUrl } = opts;
|
const { to, parentName, authorName, message, dashboardUrl } = opts;
|
||||||
|
|
||||||
await resend.emails.send({
|
await resend.emails.send({
|
||||||
|
|||||||
@@ -74,8 +74,11 @@ async function notifyMentionedParents(
|
|||||||
.collection('fams')
|
.collection('fams')
|
||||||
.getOne(famId)
|
.getOne(famId)
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
|
// Don't send emails for the demo family.
|
||||||
|
if (fam?.slug === 'showboaters') return;
|
||||||
const dashboardUrl = `${siteUrl}/${fam?.slug || famId}`;
|
const dashboardUrl = `${siteUrl}/${fam?.slug || famId}`;
|
||||||
for (const parent of mentioned) {
|
for (const parent of mentioned) {
|
||||||
|
try {
|
||||||
await sendMentionEmail({
|
await sendMentionEmail({
|
||||||
to: parent.email,
|
to: parent.email,
|
||||||
parentName: parent.name || 'there',
|
parentName: parent.name || 'there',
|
||||||
@@ -83,6 +86,9 @@ async function notifyMentionedParents(
|
|||||||
message: content,
|
message: content,
|
||||||
dashboardUrl
|
dashboardUrl
|
||||||
});
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`[chat] Failed to send mention email to ${parent.email}:`, err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,22 +163,24 @@ class ChatStore {
|
|||||||
if (record.authorId !== this.actorId) {
|
if (record.authorId !== this.actorId) {
|
||||||
if (!this.open) this.unread++;
|
if (!this.open) this.unread++;
|
||||||
this.playDunk();
|
this.playDunk();
|
||||||
this.notifyIfMentioned(record);
|
if (this.notifyIfMentioned(record) && this.open) this.unread++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toast the current user when a message @mentions them by name.
|
// Toast the current user when a message @mentions them by name.
|
||||||
private notifyIfMentioned(record: ChatMessage) {
|
// Returns true if the user was mentioned.
|
||||||
|
private notifyIfMentioned(record: ChatMessage): boolean {
|
||||||
const lower = (record.content || '').toLowerCase();
|
const lower = (record.content || '').toLowerCase();
|
||||||
const me = this.members.find((m) => m.id === this.actorId);
|
const me = this.members.find((m) => m.id === this.actorId);
|
||||||
if (!me || !me.name) return;
|
if (!me || !me.name) return false;
|
||||||
if (!lower.includes('@' + me.name.toLowerCase())) return;
|
if (!lower.includes('@' + me.name.toLowerCase())) return false;
|
||||||
addAutoDismissNotice({
|
addAutoDismissNotice({
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'You were mentioned 👋',
|
title: 'You were mentioned 👋',
|
||||||
message: `${record.authorName || 'Someone'}: ${record.content}`,
|
message: `${record.authorName || 'Someone'}: ${record.content}`,
|
||||||
dismissible: true
|
dismissible: true
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onTyping(action: string, record: TypingRow) {
|
private onTyping(action: string, record: TypingRow) {
|
||||||
|
|||||||
Reference in New Issue
Block a user