progress in removing core

This commit is contained in:
Kevin Froman 2019-07-18 18:07:18 -05:00
parent 1775b96a04
commit dbbefafd19
22 changed files with 224 additions and 75 deletions

View file

@ -17,7 +17,7 @@
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, json
import json
from onionrusers import contactmanager
from flask import Blueprint, Response, request, abort, redirect
@ -26,31 +26,30 @@ friends = Blueprint('friends', __name__)
@friends.route('/friends/list')
def list_friends():
pubkey_list = {}
c = core.Core()
friend_list = contactmanager.ContactManager.list_friends(c)
friend_list = contactmanager.ContactManager.list_friends()
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)
contactmanager.ContactManager(pubkey, saveUser=True).setTrust(1)
return redirect(request.referrer + '#' + request.form['token'])
@friends.route('/friends/remove/<pubkey>', methods=['POST'])
def remove_friend(pubkey):
contactmanager.ContactManager(core.Core(), pubkey).setTrust(0)
contactmanager.ContactManager(pubkey).setTrust(0)
return redirect(request.referrer + '#' + request.form['token'])
@friends.route('/friends/setinfo/<pubkey>/<key>', methods=['POST'])
def set_info(pubkey, key):
data = request.form['data']
contactmanager.ContactManager(core.Core(), pubkey).set_info(key, data)
contactmanager.ContactManager(pubkey).set_info(key, data)
return redirect(request.referrer + '#' + request.form['token'])
@friends.route('/friends/getinfo/<pubkey>/<key>')
def get_info(pubkey, key):
retData = contactmanager.ContactManager(core.Core(), pubkey).get_info(key)
retData = contactmanager.ContactManager(pubkey).get_info(key)
if retData is None:
abort(404)
else: