From bf9b244180972c30393ec821779d3105d7bdd52a Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 6 Aug 2019 00:49:31 -0500 Subject: [PATCH] fixed some bugs --- CONTRIBUTING.md | 2 +- onionr/static-data/bootstrap-nodes.txt | 2 +- .../static-data/default-plugins/flow/flowapi.py | 2 +- onionr/static-data/default-plugins/flow/main.py | 16 ++++++---------- onionr/static-data/www/board/board.js | 3 ++- onionr/static-data/www/shared/main/stats.js | 3 ++- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 11c5941b..25cc7d77 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,6 +28,6 @@ Do your best to use good english. For any non-trivial changes, please get in touch with us first to discuss your plans. -Please try to use a similar coding style as the project. +Please try to use a similar coding style as the project. We like PEP-8 despite being lazy with it in the past. **Thanks for contributing to Onionr!** diff --git a/onionr/static-data/bootstrap-nodes.txt b/onionr/static-data/bootstrap-nodes.txt index ce3ca75c..0201f0fd 100755 --- a/onionr/static-data/bootstrap-nodes.txt +++ b/onionr/static-data/bootstrap-nodes.txt @@ -1 +1 @@ -ouodhqewz7x7sajdnbeixmffnuzjxpv2z6djuiqkjloywepcsmfkazqd.onion \ No newline at end of file +3msj7fgyxgpfsjvvtcji7a4tkjbna6jmpealv6mun7435jjyptctfxyd.onion \ No newline at end of file diff --git a/onionr/static-data/default-plugins/flow/flowapi.py b/onionr/static-data/default-plugins/flow/flowapi.py index 40e98145..d52743c5 100755 --- a/onionr/static-data/default-plugins/flow/flowapi.py +++ b/onionr/static-data/default-plugins/flow/flowapi.py @@ -22,10 +22,10 @@ from flask import Response, request, redirect, Blueprint, abort from utils import identifyhome import deadsimplekv as simplekv flask_blueprint = Blueprint('flow', __name__) -board_cache = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/board-index.cache.json') @flask_blueprint.route('/flow/getpostsbyboard/') def get_post_by_board(board): + board_cache = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/board-index.cache.json') board_cache.refresh() posts = board_cache.get(board) if posts is None: diff --git a/onionr/static-data/default-plugins/flow/main.py b/onionr/static-data/default-plugins/flow/main.py index 52da5431..29e9a012 100755 --- a/onionr/static-data/default-plugins/flow/main.py +++ b/onionr/static-data/default-plugins/flow/main.py @@ -33,7 +33,6 @@ flask_blueprint = flowapi.flask_blueprint plugin_name = 'flow' PLUGIN_VERSION = '0.0.1' -board_cache = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/board-index.cache.json') class OnionrFlow: def __init__(self): @@ -105,16 +104,14 @@ def on_init(api, data = None): inputted is executed. Could be called when daemon is starting or when just the client is running. ''' - # Doing this makes it so that the other functions can access the api object - # by simply referencing the variable `pluginapi`. - global pluginapi - pluginapi = api + return def on_processblocks(api, data=None): - b_hash = reconstructhash.deconstruct_hash(data['block'].hash) # Get the 0-truncated block hash metadata = data['block'].bmetadata # Get the block metadata - if data['block'].bheader['type'] != 'brd': + if data['type'] != 'brd': return + b_hash = reconstructhash.deconstruct_hash(data['block'].hash) # Get the 0-truncated block hash + board_cache = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/board-index.cache.json') # get the board index cache # Validate the channel name is sane for caching try: @@ -130,11 +127,10 @@ def on_processblocks(api, data=None): existing_posts = board_cache.get(ch) if existing_posts is None: existing_posts = '' - else: - existing_posts += ',' + check_list = existing_posts.split(',') if len(check_list) > 30: check_list.pop(0) existing_posts = ','.join(check_list) - board_cache.put(ch, '%s%s' % (existing_posts, b_hash)) + board_cache.put(ch, '%s,%s' % (existing_posts, b_hash)) board_cache.flush() \ No newline at end of file diff --git a/onionr/static-data/www/board/board.js b/onionr/static-data/www/board/board.js index 8b39a0fd..38e86ff0 100755 --- a/onionr/static-data/www/board/board.js +++ b/onionr/static-data/www/board/board.js @@ -94,7 +94,7 @@ newPostForm.onsubmit = function(){ var message = document.getElementById('newMsgText').value var channel = document.getElementById('feedIDInput').value var meta = {'ch': channel} - var postData = {'message': message, 'type': 'txt', 'encrypt': false, 'meta': JSON.stringify(meta)} + var postData = {'message': message, 'type': 'brd', 'encrypt': false, 'meta': JSON.stringify(meta)} postData = JSON.stringify(postData) newPostForm.style.display = 'none' fetch('/insertblock', { @@ -108,6 +108,7 @@ newPostForm.onsubmit = function(){ .then(function(data) { newPostForm.style.display = 'block' alert('Queued for submission!') + setTimeout(function(){getBlocks()}, 3000) }) return false } \ No newline at end of file diff --git a/onionr/static-data/www/shared/main/stats.js b/onionr/static-data/www/shared/main/stats.js index 9b50185e..9e769b28 100755 --- a/onionr/static-data/www/shared/main/stats.js +++ b/onionr/static-data/www/shared/main/stats.js @@ -67,4 +67,5 @@ function getStats(){ } lastIncoming.innerText = lastConnect } -getStats() \ No newline at end of file +getStats() +setInterval(function(){getStats()}, 10000) \ No newline at end of file