diff --git a/onionr/communicatorutils/lookupblocks.py b/onionr/communicatorutils/lookupblocks.py index 8e67e688..176422b4 100755 --- a/onionr/communicatorutils/lookupblocks.py +++ b/onionr/communicatorutils/lookupblocks.py @@ -21,6 +21,7 @@ import logger, onionrproofs from onionrutils import stringvalidators, epoch from communicator import peeraction, onlinepeers from coredb import blockmetadb +from utils import reconstructhash import onionrblacklist blacklist = onionrblacklist.OnionrBlackList() def lookup_blocks_from_communicator(comm_inst): @@ -70,6 +71,7 @@ def lookup_blocks_from_communicator(comm_inst): # if request was a success for i in newBlocks.split('\n'): if stringvalidators.validate_hash(i): + i = reconstructhash.reconstruct_hash(i) # if newline seperated string is valid hash if not i in existingBlocks: # if block does not exist on disk and is not already in block queue diff --git a/onionr/httpapi/miscpublicapi/getblocks.py b/onionr/httpapi/miscpublicapi/getblocks.py index 9092e9f1..306c0a34 100755 --- a/onionr/httpapi/miscpublicapi/getblocks.py +++ b/onionr/httpapi/miscpublicapi/getblocks.py @@ -21,17 +21,20 @@ from flask import Response, abort import config from onionrutils import bytesconverter, stringvalidators from coredb import blockmetadb - +from utils import reconstructhash def get_public_block_list(clientAPI, publicAPI, request): # Provide a list of our blocks, with a date offset dateAdjust = request.args.get('date') bList = blockmetadb.get_block_list(dateRec=dateAdjust) + share_list = '' if clientAPI.config.get('general.hide_created_blocks', True): for b in publicAPI.hideBlocks: if b in bList: # Don't share blocks we created if they haven't been *uploaded* yet, makes it harder to find who created a block bList.remove(b) - return Response('\n'.join(bList)) + for b in bList: + share_list += '%s\n' % (reconstructhash.deconstruct_hash(b),) + return Response(share_list) def get_block_data(clientAPI, publicAPI, data): '''data is the block hash in hex''' diff --git a/onionr/static-data/default-plugins/esoteric/controlapi.py b/onionr/static-data/default-plugins/chat/controlapi.py similarity index 85% rename from onionr/static-data/default-plugins/esoteric/controlapi.py rename to onionr/static-data/default-plugins/chat/controlapi.py index d7b5579d..f5a0abcf 100755 --- a/onionr/static-data/default-plugins/esoteric/controlapi.py +++ b/onionr/static-data/default-plugins/chat/controlapi.py @@ -21,13 +21,13 @@ import json from flask import Response, request, redirect, Blueprint, send_from_directory import deadsimplekv as simplekv import filepaths -flask_blueprint = Blueprint('esoteric_control', __name__) +flask_blueprint = Blueprint('chat_control', __name__) key_store = simplekv.DeadSimpleKV(filepaths.cached_storage, refresh_seconds=5) -@flask_blueprint.route('/esoteric/ping') +@flask_blueprint.route('/chatapi/ping') def ping(): return 'pong!' -@flask_blueprint.route('/esoteric/send/', methods=['POST']) +@flask_blueprint.route('/chatapi/send/', methods=['POST']) def send_message(peer): data = request.get_json(force=True) key_store.refresh() @@ -39,14 +39,14 @@ def send_message(peer): key_store.flush() return Response('success') -@flask_blueprint.route('/esoteric/gets/') +@flask_blueprint.route('/chatapi/gets/') def get_sent(peer): sent = key_store.get('s' + peer) if sent is None: sent = [] return Response(json.dumps(sent)) -@flask_blueprint.route('/esoteric/addrec/', methods=['POST']) +@flask_blueprint.route('/chatapi/addrec/', methods=['POST']) def add_rec(peer): data = request.get_json(force=True) key_store.refresh() @@ -58,7 +58,7 @@ def add_rec(peer): key_store.flush() return Response('success') -@flask_blueprint.route('/esoteric/getrec/') +@flask_blueprint.route('/chatapi/getrec/') def get_messages(peer): key_store.refresh() existing = key_store.get('r' + peer) diff --git a/onionr/static-data/default-plugins/esoteric/info.json b/onionr/static-data/default-plugins/chat/info.json similarity index 67% rename from onionr/static-data/default-plugins/esoteric/info.json rename to onionr/static-data/default-plugins/chat/info.json index 6fcc6e0e..a35a28fc 100755 --- a/onionr/static-data/default-plugins/esoteric/info.json +++ b/onionr/static-data/default-plugins/chat/info.json @@ -1,5 +1,5 @@ { - "name" : "esoteric", + "name" : "chat", "version" : "1.0", "author" : "onionr" } diff --git a/onionr/static-data/default-plugins/esoteric/main.py b/onionr/static-data/default-plugins/chat/main.py similarity index 92% rename from onionr/static-data/default-plugins/esoteric/main.py rename to onionr/static-data/default-plugins/chat/main.py index c412da89..fbf00193 100755 --- a/onionr/static-data/default-plugins/esoteric/main.py +++ b/onionr/static-data/default-plugins/chat/main.py @@ -25,7 +25,7 @@ import onionrservices, logger, config from onionrservices import bootstrapservice from onionrutils import stringvalidators, epoch, basicrequests -plugin_name = 'esoteric' +plugin_name = 'chat' PLUGIN_VERSION = '0.0.0' sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) import controlapi, peerserver @@ -37,7 +37,7 @@ def exit_with_error(text=''): logger.error(text) sys.exit(1) -class Esoteric: +class Chat: def __init__(self, pluginapi): self.peer = None self.transport = None @@ -58,7 +58,7 @@ class Esoteric: message += '\n' except EOFError: message = json.dumps({'m': message, 't': epoch.get_epoch()}) - print(basicrequests.do_post_request('http://%s/esoteric/sendto' % (self.transport,), port=self.socks, data=message)) + print(basicrequests.do_post_request('http://%s/chat/sendto' % (self.transport,), port=self.socks, data=message)) message = '' except KeyboardInterrupt: self.shutdown = True @@ -89,6 +89,6 @@ def on_init(api, data = None): ''' pluginapi = api - chat = Esoteric(pluginapi) - api.commands.register(['esoteric'], chat.create) + chat = chat(pluginapi) + api.commands.register(['chat'], chat.create) return diff --git a/onionr/static-data/default-plugins/esoteric/peerserver.py b/onionr/static-data/default-plugins/chat/peerserver.py similarity index 80% rename from onionr/static-data/default-plugins/esoteric/peerserver.py rename to onionr/static-data/default-plugins/chat/peerserver.py index 5c1d02ed..8e40cefe 100755 --- a/onionr/static-data/default-plugins/esoteric/peerserver.py +++ b/onionr/static-data/default-plugins/chat/peerserver.py @@ -23,7 +23,7 @@ from onionrutils import localcommand import deadsimplekv as simplekv, filepaths from flask import Response, request, redirect, Blueprint, abort, g sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) -direct_blueprint = Blueprint('esoteric', __name__) +direct_blueprint = Blueprint('chat', __name__) key_store = simplekv.DeadSimpleKV(filepaths.cached_storage, refresh_seconds=5) storage_dir = identifyhome.identify_home() @@ -37,11 +37,11 @@ def request_setup(): g.host = host g.peer = key_store.get('dc-' + g.host) -@direct_blueprint.route('/esoteric/ping') +@direct_blueprint.route('/chat/ping') def pingdirect(): return 'pong!' -@direct_blueprint.route('/esoteric/sendto', methods=['POST', 'GET']) +@direct_blueprint.route('/chat/sendto', methods=['POST', 'GET']) def sendto(): try: msg = request.get_json(force=True) @@ -49,9 +49,9 @@ def sendto(): msg = '' else: msg = json.dumps(msg) - localcommand.local_command('/esoteric/addrec/%s' % (g.peer,), post=True, postData=msg) + localcommand.local_command('/chat/addrec/%s' % (g.peer,), post=True, postData=msg) return Response('success') -@direct_blueprint.route('/esoteric/poll') +@direct_blueprint.route('/chat/poll') def poll_chat(): - return Response(localcommand.local_command('/esoteric/gets/%s' % (g.peer,))) \ No newline at end of file + return Response(localcommand.local_command('/chat/gets/%s' % (g.peer,))) \ No newline at end of file diff --git a/onionr/static-data/www/board/index.html b/onionr/static-data/www/board/index.html index f3b13bb5..e7e4e779 100755 --- a/onionr/static-data/www/board/index.html +++ b/onionr/static-data/www/board/index.html @@ -38,6 +38,7 @@ Mail Friends Circles + Chat diff --git a/onionr/static-data/www/chat/css/convos.css b/onionr/static-data/www/chat/css/convos.css index 12b8aa0e..7196e84f 100644 --- a/onionr/static-data/www/chat/css/convos.css +++ b/onionr/static-data/www/chat/css/convos.css @@ -5,6 +5,11 @@ .convoListContainer{ margin-left: 1%; - border-radius: 10px solid black; - min-height: 100%; + border-radius: 5px; + border: 1px solid black; + overflow-y: scroll; +} + +.chatContent{ + padding-right: 5%; } \ No newline at end of file diff --git a/onionr/static-data/www/chat/index.html b/onionr/static-data/www/chat/index.html index 6b66a29f..2616a5ef 100755 --- a/onionr/static-data/www/chat/index.html +++ b/onionr/static-data/www/chat/index.html @@ -78,11 +78,11 @@
-
-
+
+
    -
    +
    yeet
    diff --git a/onionr/static-data/www/chat/js/main.js b/onionr/static-data/www/chat/js/main.js index baa3ab56..9d370301 100755 --- a/onionr/static-data/www/chat/js/main.js +++ b/onionr/static-data/www/chat/js/main.js @@ -25,4 +25,14 @@ fetch('/friends/list', { friendList[keys[i]] = resp[keys[i]]['name'] } createConvoList() -}) \ No newline at end of file +}) + +// Correct conversation list height +function correctConvoList(){ + margin = 50 + els = document.getElementsByClassName('convoListContainer') + for (x = 0; x < els.length; x++){ + els[x].style.height = window.innerHeight - (2 * margin) + 'px' + } +} +setInterval(function(){correctConvoList()}, 30) \ No newline at end of file diff --git a/onionr/static-data/www/friends/index.html b/onionr/static-data/www/friends/index.html index 0df4805a..0769c4ed 100755 --- a/onionr/static-data/www/friends/index.html +++ b/onionr/static-data/www/friends/index.html @@ -36,6 +36,7 @@ Mail Friends Circles + Chat
    diff --git a/onionr/static-data/www/mail/index.html b/onionr/static-data/www/mail/index.html index b02b27d1..3cfeae30 100755 --- a/onionr/static-data/www/mail/index.html +++ b/onionr/static-data/www/mail/index.html @@ -36,6 +36,7 @@ Mail Friends Circles + Chat diff --git a/onionr/static-data/www/private/index.html b/onionr/static-data/www/private/index.html index 6b09f976..69fd6e11 100755 --- a/onionr/static-data/www/private/index.html +++ b/onionr/static-data/www/private/index.html @@ -40,6 +40,7 @@ Mail Friends Circles + Chat diff --git a/onionr/tests/test_keymanager.py b/onionr/tests/test_keymanager.py index 0489fa98..34967536 100644 --- a/onionr/tests/test_keymanager.py +++ b/onionr/tests/test_keymanager.py @@ -35,5 +35,4 @@ class KeyManagerTest(unittest.TestCase): with open(filepaths.keys_file, 'r') as keyfile: self.assertNotIn(new_key, keyfile.read()) - unittest.main() \ No newline at end of file