Don't send user updates to friends via chat if you know their mailbox

pull/1/head
yflory 5 years ago
parent 772ecb7365
commit d190b8acd0

@ -83,6 +83,9 @@ define([
store.messenger.updateMyData();
}
var myData = createData(store.proxy);
if (store.proxy.friends) {
store.proxy.friends.me = myData;
}
var todo = function (friend) {
if (!friend || !friend.notifications) { return; }
myData.channel = friend.channel;

@ -229,6 +229,11 @@ define([
});
};
messenger.onFriendUpdate = function (curve) {
var friend = getFriend(proxy, curve);
checkFriendData(curve, friend, friend.channel);
};
// Id message allows us to map a netfluxId with a public curve key
var onIdMessage = function (msg, sender) {
var channel, parsed0;
@ -373,12 +378,14 @@ define([
|| mySyncData.profile !== myData.profile
|| mySyncData.avatar !== myData.avatar) {
delete myData.channel;
Object.keys(channels).forEach(function (chan) {
var channel = channels[chan];
Object.keys(friends).forEach(function (curve) {
var friend = friends[curve];
var chan = friend.channel;
if (friend.notifications) { return; }
if (!chan) { return; }
if (!channel) {
return void console.error('NO_SUCH_CHANNEL');
}
var channel = channels[chan];
if (!channel) { return; }
if (channel.readOnly) { return; }
var msg = [Types.update, myData.curvePublic, +new Date(), myData];
@ -396,7 +403,6 @@ define([
info: myData,
types: ['displayName', 'profile', 'avatar'],
});
friends.me = myData;
}
};

@ -153,6 +153,9 @@ define([
Object.keys(msg.content).forEach(function (key) {
friend[key] = msg.content[key];
});
if (ctx.store.messenger) {
ctx.store.messenger.onFriendUpdate(curve, friend);
}
ctx.updateMetadata();
cb(true);
};

Loading…
Cancel
Save