Adds signature in return

This commit is contained in:
Oleg Silkin 2019-05-20 02:28:04 -04:00
parent fb32bbefb1
commit c7912becf8
3 changed files with 4 additions and 6 deletions

View file

@ -37,8 +37,8 @@ CREATE INDEX COMMENT_CLAIM_INDEX ON COMMENT (LbryClaimId);
-- VIEWS -- VIEWS
DROP VIEW IF EXISTS COMMENTS_ON_CLAIMS; DROP VIEW IF EXISTS COMMENTS_ON_CLAIMS;
CREATE VIEW COMMENTS_ON_CLAIMS (comment_id, claim_id, timestamp, channel_name, channel_id, channel_uri, comment, parent_id) AS CREATE VIEW COMMENTS_ON_CLAIMS (comment_id, claim_id, timestamp, channel_name, channel_id, channel_uri, signature, parent_id, comment) AS
SELECT C.CommentId, C.LbryClaimId, C.Timestamp, CHAN.Name, CHAN.ClaimId, 'lbry://' || CHAN.Name || '#' || CHAN.ClaimId, C.Body, C.ParentId SELECT C.CommentId, C.LbryClaimId, C.Timestamp, CHAN.Name, CHAN.ClaimId, 'lbry://' || CHAN.Name || '#' || CHAN.ClaimId, C.Signature, C.ParentId, C.Body
FROM CHANNEL AS CHAN FROM CHANNEL AS CHAN
INNER JOIN COMMENT C on CHAN.ClaimId = C.ChannelId INNER JOIN COMMENT C on CHAN.ClaimId = C.ChannelId
ORDER BY C.Timestamp; ORDER BY C.Timestamp;

View file

@ -77,7 +77,7 @@ class DatabaseConnection:
) )
def _insert_comment(self, claim_id: str = None, comment: str = None, def _insert_comment(self, claim_id: str = None, comment: str = None,
channel_id: str = None, sig: str = None, channel_id: str = None, signature: str = None,
parent_id: str = None, **kwargs): parent_id: str = None, **kwargs):
timestamp = time.time_ns() timestamp = time.time_ns()
comment_prehash = ':'.join((claim_id, comment, str(timestamp),)) comment_prehash = ':'.join((claim_id, comment, str(timestamp),))
@ -90,7 +90,7 @@ class DatabaseConnection:
ParentId, Signature, Timestamp) ParentId, Signature, Timestamp)
VALUES (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
""", """,
(comment_id, claim_id, channel_id, comment, parent_id, sig, timestamp) (comment_id, claim_id, channel_id, comment, parent_id, signature, timestamp)
) )
return comment_id return comment_id

View file

@ -89,14 +89,12 @@ class CommentServer:
return web.json_response(response) return web.json_response(response)
else: else:
return web.json_response({'error': ERRORS['UNKNOWN']}) return web.json_response({'error': ERRORS['UNKNOWN']})
except
except json.decoder.JSONDecodeError as jde: except json.decoder.JSONDecodeError as jde:
return web.json_response({ return web.json_response({
'error': {'message': jde.msg, 'code': -1} 'error': {'message': jde.msg, 'code': -1}
}) })
if __name__ == '__main__': if __name__ == '__main__':
app = CommentServer() app = CommentServer()
asyncio.run(app.run()) asyncio.run(app.run())