From 0340b45f2c296b94a5d087f2113dc73a1fae3f21 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 13 Jul 2017 17:45:13 +0200 Subject: [PATCH] migrate profile to include edKey. don't propose connecting to users with whom you are already friends --- www/profile/main.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/www/profile/main.js b/www/profile/main.js index c19843948..03ec334d8 100644 --- a/www/profile/main.js +++ b/www/profile/main.js @@ -158,14 +158,22 @@ define([ }; */ + var isFriend = function (proxy, edKey) { + var friends = Cryptpad.find(proxy, ['friends']); + return typeof(edKey) === 'string' && friends && (edKey in friends); + }; + var addCreateInviteLinkButton = function ($container) { var obj = APP.lm.proxy; var proxy = Cryptpad.getProxy(); var userViewHash = Cryptpad.find(proxy, ['profile', 'view']); - if (!APP.readOnly || !obj.curveKey || userViewHash === window.location.hash.slice(1)) { - console.log("edit mode or missing curve key, or you're viewing your own profile"); + var edKey = obj.edKey; + var curveKey = obj.curveKey; + + if (!APP.readOnly || !curveKey || !edKey || userViewHash === window.location.hash.slice(1) || isFriend(proxy, edKey)) { + //console.log("edit mode or missing curve key, or you're viewing your own profile"); return; } @@ -431,6 +439,7 @@ define([ var pubKeys = Cryptpad.getPublicKeys(); if (pubKeys && pubKeys.curve) { obj.curveKey = pubKeys.curve; + obj.edKey = pubKeys.ed; } }