Reformat files

This commit is contained in:
Oleg Silkin 2019-12-30 17:21:44 -05:00
parent caef26ed4b
commit fda095c195
5 changed files with 52 additions and 49 deletions

View file

@ -44,8 +44,8 @@ CREATE TABLE IF NOT EXISTS CHANNEL
-- CREATE INDEX IF NOT EXISTS CHANNEL_COMMENT_INDEX ON COMMENT (ChannelId, CommentId);
-- VIEWS
CREATE VIEW IF NOT EXISTS COMMENTS_ON_CLAIMS AS SELECT
C.CommentId AS comment_id,
CREATE VIEW IF NOT EXISTS COMMENTS_ON_CLAIMS AS
SELECT C.CommentId AS comment_id,
C.Body AS comment,
C.LbryClaimId AS claim_id,
C.Timestamp AS timestamp,

View file

@ -1,17 +1,16 @@
import atexit
import logging
import math
import sqlite3
import time
import typing
import math
import nacl.hash
from src.database.schema import CREATE_TABLES_QUERY
logger = logging.getLogger(__name__)
SELECT_COMMENTS_ON_CLAIMS = """
SELECT comment, comment_id, channel_name, channel_id, channel_url,
timestamp, signature, signing_ts, parent_id, is_hidden

View file

@ -74,4 +74,3 @@ CREATE_TABLES_QUERY = (
CREATE_COMMENTS_ON_CLAIMS_VIEW +
CREATE_COMMENT_REPLIES_VIEW
)

View file

@ -1,6 +1,5 @@
import logging
import sqlite3
from asyncio import coroutine
from src.database.queries import delete_comment_by_id, get_comments_by_id
@ -38,7 +37,7 @@ def create_comment_or_error(conn, comment, claim_id, channel_id=None, channel_na
def insert_channel_or_error(conn: sqlite3.Connection, channel_name: str, channel_id: str):
try:
channel_matches_pattern_or_error(channel_id, channel_name)
is_valid_channel(channel_id, channel_name)
insert_channel(conn, channel_name, channel_id)
except AssertionError:
logger.exception('Invalid channel values given')
@ -63,17 +62,6 @@ async def abandon_comment(app, comment_id): # DELETE
""" Core Functions called by request handlers """
async def abandon_comment_if_authorized(app, comment_id, channel_id, signature, signing_ts, **kwargs):
claim = await get_claim_from_id(app, channel_id)
if not validate_signature_from_claim(claim, signature, signing_ts, comment_id):
return False
comment = get_comment_or_none(app['reader'], comment_id)
job = await app['comment_scheduler'].spawn(abandon_comment(app, comment_id))
await app['webhooks'].spawn(send_notification(app, 'DELETE', comment))
return await job.wait()
async def create_comment(app, params):
if is_valid_base_comment(**params) and is_valid_credential_input(**params):
job = await app['comment_scheduler'].spawn(write_comment(app, params))
@ -113,3 +101,20 @@ async def hide_comments_where_authorized(app, pieces: list) -> list:
await job.wait()
return comment_ids
async def edit_comment(app, comment_id, new_comment, channel_id,
channel_name, new_signature, new_signing_ts):
pass
async def abandon_comment_if_authorized(app, comment_id, channel_id, signature, signing_ts, **kwargs):
channel = await get_claim_from_id(app, channel_id)
if not validate_signature_from_claim(channel, signature, signing_ts, comment_id):
return False
comment = get_comment_or_none(app['reader'], comment_id)
job = await app['comment_scheduler'].spawn(abandon_comment(app, comment_id))
await app['webhooks'].spawn(send_notification(app, 'DELETE', comment))
return await job.wait()

View file

@ -1,10 +1,10 @@
import logging.config
import logging
import argparse
import logging
import logging.config
import sys
from src.settings import config
from src.server.app import run_app
from src.settings import config
def config_logging_from_settings(conf):