v.0.3.6 message input box update
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jama-backend",
|
||||
"version": "0.3.5",
|
||||
"version": "0.3.6",
|
||||
"description": "TeamChat backend server",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -211,11 +211,14 @@ io.on('connection', (socket) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Process @mentions
|
||||
// Process @mentions — format is @[display name], look up user by display_name or name
|
||||
if (content) {
|
||||
const mentions = content.match(/@\[([^\]]+)\]\((\d+)\)/g) || [];
|
||||
for (const mention of mentions) {
|
||||
const matchId = mention.match(/\((\d+)\)/)?.[1];
|
||||
const mentionNames = [...new Set((content.match(/@\[([^\]]+)\]/g) || []).map(m => m.slice(2, -1)))];
|
||||
for (const mentionName of mentionNames) {
|
||||
const mentionedUser = db.prepare(
|
||||
"SELECT id FROM users WHERE status = 'active' AND (LOWER(display_name) = LOWER(?) OR LOWER(name) = LOWER(?))"
|
||||
).get(mentionName, mentionName);
|
||||
const matchId = mentionedUser?.id?.toString();
|
||||
if (matchId && parseInt(matchId) !== userId) {
|
||||
const notifResult = db.prepare(`
|
||||
INSERT INTO notifications (user_id, type, message_id, group_id, from_user_id)
|
||||
@@ -240,7 +243,7 @@ io.on('connection', (socket) => {
|
||||
const senderName = socket.user?.display_name || socket.user?.name || 'Someone';
|
||||
sendPushToUser(mentionedUserId, {
|
||||
title: `${senderName} mentioned you`,
|
||||
body: (content || '').replace(/@\[[^\]]+\]\(\d+\)/g, (m) => '@' + m.match(/\[([^\]]+)\]/)?.[1]).slice(0, 100),
|
||||
body: (content || '').replace(/@\[([^\]]+)\]/g, '@$1').slice(0, 100),
|
||||
url: '/',
|
||||
badge: 1,
|
||||
}).catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user