Merge remote-tracking branch 'origin/message_notifs_2' into 2026.4-rc

This commit is contained in:
yflory 2026-05-06 14:17:35 +02:00
commit 2433a16c2b
5 changed files with 70 additions and 3 deletions

View File

@ -170,6 +170,8 @@ define(req, function(AppConfig, Default, Language) {
// "form_input_ph_url": "https://example.com",
Messages.form_date_time = "Select date and time";
Messages.sent_chatMessage = "{0} has sent you a message"; // XXX
return Messages;
});

View File

@ -859,6 +859,22 @@ const factory = (Messaging, Hash, Util, Crypto, Block) => {
delete sfDeleted[id];
};
var msgNotif = {};
handlers['SEND_CHAT_MESSAGE'] = function (ctx, box, data, cb) {
var msgSender = data.msg.author;
//Check if sender is in contacts and not muted
if (msgNotif[msgSender] || isMuted(ctx, data) || !ctx.store.proxy.friends[msgSender]) { return void cb(true); }
msgNotif[msgSender] = 1;
cb(false);
};
removeHandlers['SEND_CHAT_MESSAGE'] = function (ctx, box, data) {
var msgSender = data.author;
delete msgNotif[msgSender];
};
// New support
handlers['NEW_TICKET'] = function (ctx, box, data, cb) {
var msg = data.msg;

View File

@ -8,12 +8,14 @@ define([
'/common/common-util.js',
'/common/common-interface.js',
'/common/common-ui-elements.js',
'/common/visible.js',
'/common/notify.js',
'/common/inner/badges.js',
'/common/hyperscript.js',
'/common/diffMarked.js',
'/common/common-icons.js',
'/customize/pages.js',
], function ($, Messages, Util, UI, UIElements, Badges, h, DiffMd, Icons, Pages) {
], function ($, Messages, Util, UI, UIElements, Visible, Notification, Badges, h, DiffMd, Icons, Pages) {
'use strict';
var debug = console.log;
@ -259,6 +261,7 @@ define([
normalizeLabels($messagebox);
scrollChatToBottom();
};
var userInfo;
markup.chatbox = function (id, data, curvePublic) {
var moreHistory = h('span', {
class: 'cp-app-contacts-more-history',
@ -444,6 +447,28 @@ define([
// failed to send
return void console.error('failed to send', e);
}
//Send mailbox message if:
//- recipient is a contact
//- recipient is offline
//- no previous messages to recipient sent while current tab is open
var messageSent = {};
execCommand('GET_STATUS', id, function (e, online) {
if (online) {
delete messageSent[id];
} else {
if (friend && !messageSent[id]) {
common.mailbox.sendTo("SEND_CHAT_MESSAGE", {
name: userInfo.displayName,
}, {
channel: contactsData[chan.curvePublic].notifications,
curvePublic: chan.curvePublic
});
messageSent[id] = true;
}
}
});
input.value = '';
sending = false;
debug('sent successfully');
@ -804,6 +829,11 @@ define([
}
notifyToolbar();
if (!Visible.currently()) {
common.notify();
Notification.create();
}
channel.messages.push(message);
var $chat = $(chat);
@ -1217,10 +1247,10 @@ define([
});
};
//});
execCommand('GET_MY_INFO', null, function (e, info) {
if (e) { return; }
contactsData[info.curvePublic] = info;
userInfo = info;
});

View File

@ -148,6 +148,25 @@ define([
}
};
// Send chat message
handlers['SEND_CHAT_MESSAGE'] = function(common, data) {
var content = data.content;
var msg = content.msg;
var key = 'sent_chatMessage';
var name = Util.fixHTML(msg.content.name) || Messages.anonymous;
content.getFormatText = function() {
return Messages._getKey(key, [name]);
};
content.handler = function() {
common.openURL('/contacts/');
defaultDismiss(common, data)();
};
if (!content.archived) {
content.dismissHandler = defaultDismiss(common, data);
}
};
// New support message from the admins
handlers['SUPPORT_MESSAGE'] = function(common, data) {
var content = data.content;

File diff suppressed because one or more lines are too long