Skip to content
Snippets Groups Projects
Commit 2f5a5da5 authored by Howo's avatar Howo Committed by Martin Lees
Browse files

Squashed commit of the following:

commit 3eb72984
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Mon Aug 22 00:18:09 2022 -0400

    Fix pattern tests following changes in mocks

commit e0ed25f8
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Aug 21 20:35:51 2022 -0400

    Added test cases in the mocks + pattern tests

commit 1144c265
Merge: 2a80d650 066762c7
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Aug 21 20:35:21 2022 -0400

    Merge branch 'feature/role-only-if-subscribed' of gitlab.syncad.com:hive/hivemind into feature/role-only-if-subscribed

commit 066762c7
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun May 8 23:13:17 2022 -0400

    Added flow.txt where it's missed

commit 6acdb300
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 24 10:46:38 2022 -0400

    fix all tests

commit 566a71ab
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sat Apr 23 22:35:34 2022 -0400

    attempt at fixing most tests

commit ec803921
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sat Apr 23 21:25:23 2022 -0400

    first fix try

commit cbb74d37
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 3 23:26:00 2022 -0400

    small fix

commit 9dc83b3b
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 3 23:23:55 2022 -0400

    Allows setting the muted role even if you're not subscribed

commit 446a4c1b
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 3 23:11:00 2022 -0400

    added communtiy_helpers to base schema

commit e710b92c
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 3 19:52:29 2022 -0400

    Update SetRole/SetUserTitle so that you have to be subscribed to get it, also added a script to generate flow.txt and cleaned up communtiy_flow

commit 2a80d650
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun May 8 23:13:17 2022 -0400

    Added flow.txt where it's missed

commit 555d03c6
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 24 10:46:38 2022 -0400

    fix all tests

commit 0b705204
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sat Apr 23 22:35:34 2022 -0400

    attempt at fixing most tests

commit 4e2946f7
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sat Apr 23 21:25:23 2022 -0400

    first fix try

commit 7c467c37
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 3 23:26:00 2022 -0400

    small fix

commit 3ecaf640
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 3 23:23:55 2022 -0400

    Allows setting the muted role even if you're not subscribed

commit 2e9081e5
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 3 23:11:00 2022 -0400

    added communtiy_helpers to base schema

commit 7f0cc6d5
Author: Martin Lees <drov0@users.noreply.github.com>
Date:   Sun Apr 3 19:52:29 2022 -0400

    Update SetRole/SetUserTitle so that you have to be subscribed to get it, also added a script to generate flow.txt and cleaned up communtiy_flow
parent 103b7ca0
No related branches found
No related tags found
No related merge requests found
Showing
with 1238 additions and 390 deletions
...@@ -693,6 +693,7 @@ def setup(db): ...@@ -693,6 +693,7 @@ def setup(db):
"update_table_statistics.sql", "update_table_statistics.sql",
"upgrade/update_db_patchlevel.sql", # Additionally execute db patchlevel import to mark (already done) upgrade changes and avoid its reevaluation during next upgrade. "upgrade/update_db_patchlevel.sql", # Additionally execute db patchlevel import to mark (already done) upgrade changes and avoid its reevaluation during next upgrade.
"hafapp_api.sql", "hafapp_api.sql",
"community_helpers.sql",
] ]
sql_scripts_dir_path = Path(__file__).parent / 'sql_scripts' sql_scripts_dir_path = Path(__file__).parent / 'sql_scripts'
......
DROP FUNCTION IF EXISTS set_community_role_or_title;
CREATE OR REPLACE FUNCTION set_community_role_or_title(_community_id hive_posts.community_id%TYPE, _account_id hive_posts.author_id%TYPE, _role_id integer, _title varchar(140), _created_at timestamp)
RETURNS bool
LANGUAGE plpgsql
as
$$
declare
__subscription_id INTEGER;
__role_id SMALLINT;
BEGIN
SELECT id INTO __subscription_id FROM hive_subscriptions WHERE account_id = _account_id AND community_id = _community_id;
IF _role_id IS NOT NULL THEN
-- We allow setting the MUTED role even if you're not subscribed
IF _role_id > 0 THEN
SELECT role_id INTO __role_id FROM hive_roles WHERE account_id = _account_id AND community_id = _community_id;
-- We don't allow setting a higher role than the current one if you aren't subscribed
IF __subscription_id IS NULL AND ((__role_id IS NOT NULL AND __role_id < _role_id ) OR __role_id IS NULL) THEN
return false;
END IF;
END IF;
ELSE
IF __subscription_id IS NULL THEN
return false;
END IF;
end if;
IF _role_id IS NOT NULL AND _title IS NULL THEN
INSERT INTO hive_roles(account_id, community_id, role_id, created_at)
VALUES (_account_id, _community_id, _role_id, _created_at)
ON CONFLICT (account_id, community_id)
DO UPDATE SET role_id = _role_id;
ELSIF _title IS NOT NULL AND _role_id IS NULL THEN
INSERT INTO hive_roles(account_id, community_id, title, created_at)
VALUES (_account_id, _community_id, _title, _created_at)
ON CONFLICT (account_id, community_id)
DO UPDATE SET title = _title;
END IF;
RETURN TRUE;
END;
$$;
...@@ -76,6 +76,7 @@ for sql in postgres_handle_view_changes.sql \ ...@@ -76,6 +76,7 @@ for sql in postgres_handle_view_changes.sql \
follows.sql \ follows.sql \
is_superuser.sql \ is_superuser.sql \
update_hive_blocks_consistency_flag.sql \ update_hive_blocks_consistency_flag.sql \
community_helpers.sql \
update_table_statistics.sql # Must be last update_table_statistics.sql # Must be last
do do
......
...@@ -201,10 +201,10 @@ class Community: ...@@ -201,10 +201,10 @@ class Community:
WHERE community_id = :community_id WHERE community_id = :community_id
AND account_id = :account_id AND account_id = :account_id
LIMIT 1""", LIMIT 1""",
community_id=community_id, community_id=community_id,
account_id=account_id, account_id=account_id,
) )
or Role.guest.value or Role.guest.value
) )
@classmethod @classmethod
...@@ -372,24 +372,22 @@ class CommunityOp: ...@@ -372,24 +372,22 @@ class CommunityOp:
# Account-level actions # Account-level actions
elif action == 'setRole': elif action == 'setRole':
DB.query( subscribed = DB.query_one(
f"""INSERT INTO {SCHEMA_NAME}.hive_roles f"""SELECT * FROM {SCHEMA_NAME}.set_community_role_or_title(:community_id, :account_id, :role_id, NULL::varchar, CAST(:date AS timestamp ))""",
(account_id, community_id, role_id, created_at)
VALUES (:account_id, :community_id, :role_id, :date)
ON CONFLICT (account_id, community_id)
DO UPDATE SET role_id = :role_id """,
**params, **params,
) )
if not subscribed:
log.info("set role failed account '%s' must be subscribed to the community", params['account'])
return
self._notify('set_role', payload=Role(self.role_id).name) self._notify('set_role', payload=Role(self.role_id).name)
elif action == 'setUserTitle': elif action == 'setUserTitle':
DB.query( subscribed = DB.query_one(
f"""INSERT INTO {SCHEMA_NAME}.hive_roles f"""SELECT * FROM {SCHEMA_NAME}.set_community_role_or_title(:community_id, :account_id, NULL::integer , :title, CAST(:date AS timestamp ))""",
(account_id, community_id, title, created_at)
VALUES (:account_id, :community_id, :title, :date)
ON CONFLICT (account_id, community_id)
DO UPDATE SET title = :title""",
**params, **params,
) )
if not subscribed:
log.info("set role failed account '%s' must be subscribed to the community", params['account'])
return
self._notify('set_label', payload=self.title) self._notify('set_label', payload=self.title)
# Post-level actions # Post-level actions
......
This diff is collapsed.
***block 4998001***
create_claimed_account_operation(`esteemapp` -> `tester1`)
create_claimed_account_operation(`esteemapp` -> `tester2`)
create_claimed_account_operation(`esteemapp` -> `tester3`)
create_claimed_account_operation(`esteemapp` -> `tester4`)
create_claimed_account_operation(`esteemapp` -> `tester5`)
create_claimed_account_operation(`esteemapp` -> `spaminator`)
create_claimed_account_operation(`esteemapp` -> `hivewatchers`)
create_claimed_account_operation(`esteemapp` -> `buildawhale`)
create_claimed_account_operation(`esteemapp` -> `redeemer`)
create_claimed_account_operation(`esteemapp` -> `ignoreall`)
create_claimed_account_operation(`esteemapp` -> `blacklisttester`)
create_claimed_account_operation(`esteemapp` -> `mutetester`)
create_claimed_account_operation(`esteemapp` -> `followtest`)
create_claimed_account_operation(`esteemapp` -> `bugtester`)
***block 4998002***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"tester3\", \"tester4\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"t'es'ter3\", \"<html><body><p>PPPPP</p></body></html>\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"tester7\", \"<script>alert('hello world');</script>\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"tester3\", \"tester4\"], \"what\": [\"blogo-doggo\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"bugtester\", \"following\": [\"funny\"], \"what\": [\"blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"bugtester\", \"following\": [\"funny\"], \"what\": [\"reset_blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"bugtester\", \"following\": [\"nkdk\", \"steemit\"], \"what\": [\"blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"blacklisttester\", \"following\": [\"nkdk\", \"steemit\"], \"what\": [\"blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"mutetester\", \"following\": [\"steemit\", \"funny\", \"peerplays\", \"skapaneas\", \"the-alien\", \"powerup\", \"lukmarcus\", \"simgregg\"], \"what\": [\"ignore\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"funny\", \"following\": [\"blacklisttester\"], \"what\": [\"follow_blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"funny\", \"following\": [\"mutetester\"], \"what\": [\"follow_muted\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"bugtester\", \"following\": [\"gtg\", \"stan\"], \"what\": [\"ignore\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"bugtester\", \"following\": [\"gtg\", \"stan\"], \"what\": [\"reset_muted_list\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"bugtester\", \"following\": [\"admin\", \"roadscape\"], \"what\": [\"ignore\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"bugtester\", \"following\": [\"blacklisttester\"], \"what\": [\"follow_blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"followtest\", \"following\": [\"mutetester\"], \"what\": [\"follow_muted\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"followtest\", \"following\": [\"blacklisttester\"], \"what\": [\"follow_blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"te'%@ter1\", \"following\": [\"tester3\", \"tester4\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester5\", \"following\": [\"tester4\"], \"what\": [\"blacklist\"]}]")
***block 4998003***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"tester3\", \"tester4\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"t'es'ter3\", \"<html><body><p>PPPPP</p></body></html>\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"tester3\", \"gtg\"], \"what\": [\"blogo-doggo\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"te'%@ter1\", \"following\": [\"gtg\", \"tester4\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": {\"tester1\": \"tester1\"}, \"following\": {\"gtg\": \"gtg\"}, \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": {\"gtg\": \"gtg\"}, \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"tester3\", [\"gtg\"]], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": [\"tester1\"], \"following\": [\"tester3\", [\"gtg\"]], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": [\"tester1\"], \"following\": [\"tester3\", {\"gtg\": \"gtg\"}], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"tester3\", {\"gtg\": \"gtg\"}], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": [\"tester7\", \"<script>alert('hello world');</script>\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"followtest\", \"following\": [\"gtg\", \"roadscape\", \"admin\", \"cryptos\"], \"what\": [\"blacklist\"]}]")
***block 4998004***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"ignore\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"spaminator\", \"following\": [\"lyubovbar\", \"zaitsevalesyaa\", \"kingscrown\", \"trevonjb\", \"craig-grant\", \"ned\", \"mindhunter\"], \"what\": [\"blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"hivewatchers\", \"following\": [\"lyubovbar\", \"rkpl\", \"blendplayz\", \"renzoarg\", \"kingscrown\", \"forevergala\", \"machinelearning\", \"ola1\", \"steembeast\", \"ekremi12\", \"steem4lyf\", \"caitlinm\", \"bruno1122\"], \"what\": [\"blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"buildawhale\", \"following\": [\"zaitsevalesyaa\", \"trevonjb\", \"earnest\", \"wildchild\", \"craig-grant\"], \"what\": [\"blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"redeemer\", \"following\": [\"zaitsevalesyaa\", \"trevonjb\", \"craig-grant\"], \"what\": [\"blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"ignoreall\", \"following\": [\"gtg\", \"alice\", \"davr86\"], \"what\": [\"blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"ignoreall\", \"following\": [\"gtg\", \"alice\", \"davr86\", \"fyrstikken\", \"gavvet\", \"ooak\", \"kental\", \"r4fken\", \"roland.haynes\", \"agartha\", \"feline1991\"], \"what\": [\"ignore\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"followtest\", \"following\": [\"admin\", \"roadscape\", \"dollarvigilante\", \"nonlinearone\", \"juanmiguelsalas\", \"laonie\", \"cheetah\"], \"what\": [\"ignore\"]}]")
***block 4998005***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"blacklist\"]}]")
***block 4998006***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"follow_blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"alice\", \"following\": [\"spaminator\", \"hivewatchers\", \"buildawhale\", \"redeemer\"], \"what\": [\"follow_blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"alice\", \"following\": \"ignoreall\", \"what\": [\"follow_muted\"]}]")
***block 4998007***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"unblacklist\"]}]")
***block 4998008***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"unfollow_blacklist\"]}]")
***block 4998009***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"follow_muted\"]}]")
***block 4998010***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"unfollow_muted\"]}]")
***block 4998011***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"reset_blacklist\"]}]")
***block 4998012***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"reset_following_list\"]}]")
***block 4998013***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"reset_follow_blacklist\"]}]")
***block 4998014***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"reset_follow_muted_list\"]}]")
***block 4998015***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"reset_all_lists\"]}]")
***block 4998016***
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester3\", \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"reset_all_lists\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester1\", \"following\": \"tester2\", \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester2\", \"following\": [\"tester3\", \"tester4\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester3\", \"following\": [\"tester4\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester4\", \"following\": [\"tester5\", \"tester1\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester5\", \"following\": [\"tester1\", \"tester2\", \"tester3\"], \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"test-follower\", \"following\": \"test-creator\", \"what\": [\"blog\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"test-muter\", \"following\": \"test-creator\", \"what\": [\"ignore\"]}]")
***block 4998017***
custom_json_operation("[\"follow\", {\"follower\": \"tester5\", \"following\": [\"tester4\"], \"what\": [\"follow_blacklist\"]}]")
custom_json_operation("[\"follow\", {\"follower\": \"tester5\", \"following\": [\"tester4\"], \"what\": [\"follow_muted\"]}]")
\ No newline at end of file
***block 1000000***
custom_json_operation("[\"setLastRead\", {\"date\": \"2021-05-26T14:21:43\"}]")
custom_json_operation("[\"setLastRead\", {\"date\": null}]")
custom_json_operation("[\"setLastRead\", {}]")
custom_json_operation("[\"setLastRead\", {\"date\": \"2016-05-26T14:21:43\"}]")
custom_json_operation("[\"setLastRead\", {\"date\": \"2099-02-26T14:21:43\"}]")
custom_json_operation("[\"setLastRead\", {\"date\": null}]")
custom_json_operation("[\"setLastRead\"]")
custom_json_operation("[\"setLastRead\", {\"date\": \"2015-02-26T14:21:43\"}]")
custom_json_operation("[\"setLastRead\", {\"date\": \"1968-02-26T14:21:43\"}]")
custom_json_operation("[\"setLastRead\", {}]")
***block 4000001***
transfer_operation( `gtg`, `null`, `0.02 HBD`, `@alice/firstpost______20` )
***block 4010001***
comment_operation( ``, `alice`,`firstpost______20`)
delete_comment_operation( `alice`, `firstpost______20`)
transfer_operation( `gtg`, `null`, `0.02 HBD`, `@alice/firstpost______20` )
***block 4020001***
transfer_operation( `gtg`, `null`, `0.02 HBD`, `@alice/firstpost______20` )
comment_operation( ``, `alice`,`firstpost______20`)
transfer_operation( `gtg`, `null`, `0.02 HBD`, `@alice/firstpost______20` )
# This script parses a json mock file and outputs a flow.txt file
import json
import argparse
def parse_custom_json(op):
data = json.loads(op['json'].replace('\n', r'\n'))
if data[0] == 'subscribe' or data[0] == 'unsubscribe':
account = op['required_posting_auths'][0]
return r'custom_json_operation("%s" -> "%s")' % (account, json.dumps(data).replace('"', r'\"'))
elif data[0] == 'updateProps':
props = json.dumps(data[1]['props']).replace('"', r'\"')
return r'custom_json_operation("[\"updateProps\",{\"community\":\"%s\",\"props\":%s}]")' % (data[1]['community'], props)
else:
return 'custom_json_operation("%s")' % (json.dumps(data).replace('"', r'\"'))
def parse_op(op):
if op['type'] == 'account_create_operation':
return 'account_create_operation( `{}` )'.format(op['value']['new_account_name'])
elif op['type'] == 'comment_operation':
return 'comment_operation( `{}`, `{}`,`{}`)'.format(op['value']['parent_permlink'], op['value']['author'], op['value']['permlink'])
elif op['type'] == 'transfer_operation':
return 'transfer_operation( `{}`, `{}`, `{}`, `{}` )'.format(op['value']['from'], op['value']['to'], op['value']['amount'], op['value']['memo'])
elif op['type'] == 'custom_json_operation':
return parse_custom_json(op['value'])
elif op['type'] == 'custom_json_operation':
return parse_custom_json(op['value'])
elif op['type'] == 'account_update2_operation':
json_metadata = json.dumps(op['value']['json_metadata'].replace('\n', '\\n')).replace('"', '\"')
return 'transfer_operation( `{}`, `{}`, `{}`)'.format(op['value']['account'], json_metadata, op['value']['posting_json_metadata'])
elif op['type'] == 'delete_comment_operation':
return 'delete_comment_operation( `{}`, `{}`)'.format(op['value']['author'], op['value']['permlink'])
elif op['type'] == 'vote_operation':
return 'delete_comment_operation(`{}` -> `{}`, `{}`, `{}`)'.format(op['value']['voter'], op['value']['author'], op['value']['permlink'], op['value']['weight'])
elif op['type'] == 'create_claimed_account_operation':
return 'create_claimed_account_operation(`{}` -> `{}`)'.format(op['value']['creator'], op['value']['new_account_name'])
else:
raise 'operation type not known'
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("file", type=str, help="Path of the mock file")
args = parser.parse_args()
f = open(args.file)
data = json.load(f)
flow_str = ''
for block_id in data:
flow_str += '***block {}***\n'.format(block_id)
operations = data[block_id]['transactions'][0]['operations']
for op in operations:
flow_str += parse_op(op) + '\n'
print(flow_str)
[ [
{ {
"date": "2016-09-15T19:44:18", "date": "2016-09-15T19:44:18",
"id": 2010430, "id": 2010444,
"msg": "@vitaly-lvov mentioned you and 1 others", "msg": "@vitaly-lvov mentioned you and 1 others",
"score": 50, "score": 50,
"type": "mention", "type": "mention",
......
[ [
{ {
"date": "2016-09-15T19:23:54", "date": "2016-09-15T19:23:54",
"id": 2010022, "id": 2010036,
"msg": "@rusla followed you", "msg": "@rusla followed you",
"score": 50, "score": 50,
"type": "follow", "type": "follow",
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
{ {
"date": "2016-09-15T18:41:03", "date": "2016-09-15T18:41:03",
"id": 2008807, "id": 2008821,
"msg": "@dolphindigest mentioned you and 10 others", "msg": "@dolphindigest mentioned you and 10 others",
"score": 50, "score": 50,
"type": "mention", "type": "mention",
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
}, },
{ {
"date": "2016-09-15T18:37:45", "date": "2016-09-15T18:37:45",
"id": 2008714, "id": 2008728,
"msg": "@dolphindigest mentioned you and 12 others", "msg": "@dolphindigest mentioned you and 12 others",
"score": 50, "score": 50,
"type": "mention", "type": "mention",
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
}, },
{ {
"date": "2016-09-15T18:18:54", "date": "2016-09-15T18:18:54",
"id": 2008115, "id": 2008129,
"msg": "@linkback-bot-v0 mentioned you and 3 others", "msg": "@linkback-bot-v0 mentioned you and 3 others",
"score": 50, "score": 50,
"type": "mention", "type": "mention",
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
}, },
{ {
"date": "2016-09-15T18:18:54", "date": "2016-09-15T18:18:54",
"id": 2008114, "id": 2008128,
"msg": "@linkback-bot-v0 replied to your post", "msg": "@linkback-bot-v0 replied to your post",
"score": 50, "score": 50,
"type": "reply", "type": "reply",
......
[ [
{ {
"date": "2016-09-15T18:55:30", "date": "2016-09-15T18:55:30",
"id": 2009369, "id": 2009383,
"msg": "@liondani voted on your post ($0.27)", "msg": "@liondani voted on your post ($0.27)",
"score": 50, "score": 50,
"type": "vote", "type": "vote",
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
{ {
"date": "2016-09-15T18:52:09", "date": "2016-09-15T18:52:09",
"id": 2009286, "id": 2009300,
"msg": "@chitty replied to your comment", "msg": "@chitty replied to your comment",
"score": 70, "score": 70,
"type": "reply_comment", "type": "reply_comment",
......
[ [
{ {
"date": "2016-09-15T18:21:03", "date": "2016-09-15T18:21:03",
"id": 2008203, "id": 2008217,
"msg": "@kushed voted on your post ($10.40)", "msg": "@kushed voted on your post ($10.40)",
"score": 100, "score": 100,
"type": "vote", "type": "vote",
......
[ [
{ {
"date": "2016-09-15T19:41:33", "date": "2016-09-15T19:41:33",
"id": 2010374, "id": 2010388,
"msg": "@nippel66 voted on your post ($0.03)", "msg": "@nippel66 voted on your post ($0.03)",
"score": 25, "score": 25,
"type": "vote", "type": "vote",
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
{ {
"date": "2016-09-15T18:57:51", "date": "2016-09-15T18:57:51",
"id": 2009431, "id": 2009445,
"msg": "@edgeland voted on your post ($0.28)", "msg": "@edgeland voted on your post ($0.28)",
"score": 50, "score": 50,
"type": "vote", "type": "vote",
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
}, },
{ {
"date": "2016-09-15T18:56:00", "date": "2016-09-15T18:56:00",
"id": 2009404, "id": 2009418,
"msg": "@kurtbeil replied to your post", "msg": "@kurtbeil replied to your post",
"score": 50, "score": 50,
"type": "reply", "type": "reply",
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
}, },
{ {
"date": "2016-09-15T18:36:15", "date": "2016-09-15T18:36:15",
"id": 2008663, "id": 2008677,
"msg": "@pjheinz followed you", "msg": "@pjheinz followed you",
"score": 60, "score": 60,
"type": "follow", "type": "follow",
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
}, },
{ {
"date": "2016-09-15T18:09:45", "date": "2016-09-15T18:09:45",
"id": 2007946, "id": 2007960,
"msg": "@honeyscribe replied to your comment", "msg": "@honeyscribe replied to your comment",
"score": 70, "score": 70,
"type": "reply_comment", "type": "reply_comment",
......
[ [
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007760, "id": 2007771,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
}, },
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007759, "id": 2007770,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
}, },
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007758, "id": 2007769,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
}, },
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007757, "id": 2007768,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
}, },
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007756, "id": 2007767,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
}, },
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007755, "id": 2007766,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
}, },
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007754, "id": 2007765,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
}, },
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007753, "id": 2007764,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
}, },
{ {
"date": "2016-09-15T18:02:03", "date": "2016-09-15T18:02:03",
"id": 2007752, "id": 2007763,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007731, "id": 2007737,
"msg": "@test-creator replied to your post", "msg": "@test-creator replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007730, "id": 2007736,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007729, "id": 2007735,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007728, "id": 2007734,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007727, "id": 2007733,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007726, "id": 2007732,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007725, "id": 2007731,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007724, "id": 2007730,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007723, "id": 2007729,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
}, },
{ {
"date": "2016-09-15T18:01:51", "date": "2016-09-15T18:01:51",
"id": 2007722, "id": 2007728,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
}, },
{ {
"date": "2016-09-15T18:01:42", "date": "2016-09-15T18:01:42",
"id": 2007684, "id": 2007693,
"msg": "@agartha reblogged your post", "msg": "@agartha reblogged your post",
"score": 40, "score": 40,
"type": "reblog", "type": "reblog",
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
}, },
{ {
"date": "2016-09-15T18:01:42", "date": "2016-09-15T18:01:42",
"id": 2007683, "id": 2007692,
"msg": "@agartha reblogged your post", "msg": "@agartha reblogged your post",
"score": 40, "score": 40,
"type": "reblog", "type": "reblog",
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007678, "id": 2007687,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007677, "id": 2007686,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007676, "id": 2007685,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007675, "id": 2007684,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007674, "id": 2007683,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007673, "id": 2007682,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007672, "id": 2007681,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007671, "id": 2007680,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007670, "id": 2007679,
"msg": "@alice replied to your post", "msg": "@alice replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
}, },
{ {
"date": "2016-09-15T18:01:39", "date": "2016-09-15T18:01:39",
"id": 2007669, "id": 2007678,
"msg": "@steemit replied to your post", "msg": "@steemit replied to your post",
"score": 40, "score": 40,
"type": "reply", "type": "reply",
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"num_authors": 3, "num_authors": 3,
"num_pending": 10, "num_pending": 10,
"settings": {}, "settings": {},
"subscribers": 2, "subscribers": 5,
"sum_pending": 0, "sum_pending": 0,
"team": [ "team": [
[ [
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"num_authors": 3, "num_authors": 3,
"num_pending": 10, "num_pending": 10,
"settings": {}, "settings": {},
"subscribers": 2, "subscribers": 5,
"sum_pending": 0, "sum_pending": 0,
"team": [ "team": [
[ [
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"avatar_url": "", "avatar_url": "",
"context": { "context": {
"role": "mod", "role": "mod",
"subscribed": false, "subscribed": true,
"title": "" "title": ""
}, },
"created_at": "2016-09-15 18:01:30", "created_at": "2016-09-15 18:01:30",
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"num_authors": 3, "num_authors": 3,
"num_pending": 10, "num_pending": 10,
"settings": {}, "settings": {},
"subscribers": 2, "subscribers": 5,
"sum_pending": 0, "sum_pending": 0,
"team": [ "team": [
[ [
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"num_authors": 3, "num_authors": 3,
"num_pending": 10, "num_pending": 10,
"settings": {}, "settings": {},
"subscribers": 2, "subscribers": 5,
"sum_pending": 0, "sum_pending": 0,
"team": [ "team": [
[ [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment