work on UI friends manager

This commit is contained in:
Kevin Froman 2019-02-21 19:55:13 -06:00
parent 4f39c5792a
commit 30a2ae8d06
7 changed files with 43 additions and 21 deletions

View file

@ -17,12 +17,20 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
'''
import core
import core, json
from onionrusers import contactmanager
from flask import Blueprint, Response, request, abort
friends = Blueprint('friends', __name__)
@friends.route('/friends/list')
def list_friends():
pubkey_list = {}
friend_list = contactmanager.ContactManager.list_friends(core.Core())
for friend in friend_list:
pubkey_list[friend.publicKey] = {'name': friend.get_info('name')}
return json.dumps(pubkey_list)
@friends.route('/friends/add/<pubkey>', methods=['POST'])
def add_friend(pubkey):
contactmanager.ContactManager(core.Core(), pubkey, saveUser=True).setTrust(1)