fixed some bugs

This commit is contained in:
Kevin Froman 2019-08-06 00:49:31 -05:00
parent 9080374d7b
commit bf9b244180
6 changed files with 13 additions and 15 deletions

View File

@ -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!**

View File

@ -1 +1 @@
ouodhqewz7x7sajdnbeixmffnuzjxpv2z6djuiqkjloywepcsmfkazqd.onion
3msj7fgyxgpfsjvvtcji7a4tkjbna6jmpealv6mun7435jjyptctfxyd.onion

View File

@ -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/<board>')
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:

View File

@ -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()

View File

@ -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
}

View File

@ -67,4 +67,5 @@ function getStats(){
}
lastIncoming.innerText = lastConnect
}
getStats()
getStats()
setInterval(function(){getStats()}, 10000)