Distinguish between two anonymous users in the chat

pull/1/head
yflory 6 years ago
parent 498703384f
commit 7d3d3cf5ac

@ -5,9 +5,10 @@ define([
'/common/common-util.js', '/common/common-util.js',
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/common-constants.js', '/common/common-constants.js',
'/customize/messages.js',
'/bower_components/nthen/index.js', '/bower_components/nthen/index.js',
], function (Crypto, Curve, Hash, Util, Realtime, Constants, nThen) { ], function (Crypto, Curve, Hash, Util, Realtime, Constants, Messages, nThen) {
'use strict'; 'use strict';
var Msg = { var Msg = {
inputs: [], inputs: [],
@ -698,7 +699,9 @@ define([
var msg = [Types.message, proxy.curvePublic, +new Date(), payload]; var msg = [Types.message, proxy.curvePublic, +new Date(), payload];
if (!channel.isFriendChat) { if (!channel.isFriendChat) {
msg.push(proxy[Constants.displayNameKey]); var name = proxy[Constants.displayNameKey] ||
Messages.anonymous + '#' + proxy.uid.slice(0,5);
msg.push(name);
} }
var msgStr = JSON.stringify(msg); var msgStr = JSON.stringify(msg);
var cryptMsg = channel.encryptor.encrypt(msgStr); var cryptMsg = channel.encryptor.encrypt(msgStr);

@ -169,14 +169,15 @@ define([
markup.message = function (msg) { markup.message = function (msg) {
if (msg.type !== 'MSG') { return; } if (msg.type !== 'MSG') { return; }
var curvePublic = msg.author; var curvePublic = msg.author;
var name = typeof msg.name !== "undefined" ? (msg.name || Messages.anonymous) var name = typeof msg.name !== "undefined" ?
: contactsData[msg.author].displayName; (msg.name || Messages.anonymous) :
contactsData[msg.author].displayName;
var d = msg.time ? new Date(msg.time) : undefined; var d = msg.time ? new Date(msg.time) : undefined;
var day = d ? d.toLocaleDateString() : ''; var day = d ? d.toLocaleDateString() : '';
var hour = d ? d.toLocaleTimeString() : ''; var hour = d ? d.toLocaleTimeString() : '';
return h('div.cp-app-contacts-message', { return h('div.cp-app-contacts-message', {
//title: time || '?', //title: time || '?',
'data-user': curvePublic, 'data-user': curvePublic || name,
'data-day': day 'data-day': day
}, [ }, [
name? h('div.cp-app-contacts-sender', [ name? h('div.cp-app-contacts-sender', [
@ -550,8 +551,9 @@ define([
common.notify(); common.notify();
if (message.type === 'MSG') { if (message.type === 'MSG') {
var name = typeof message.name !== "undefined" ? (message.name || Messages.anonymous) var name = typeof message.name !== "undefined" ?
: contactsData[message.author].displayName; (message.name || Messages.anonymous) :
contactsData[message.author].displayName;
common.notify({title: name, msg: message.text}); common.notify({title: name, msg: message.text});
} }
notifyToolbar(); notifyToolbar();

Loading…
Cancel
Save