Skip to content

Commit

Permalink
remove upvote
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheo committed Oct 3, 2024
1 parent 34a5a5e commit 40b60b8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
9 changes: 9 additions & 0 deletions indexer_app/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
handle_pot_config_update,
handle_registry_blacklist_action,
handle_registry_unblacklist_action,
handle_remove_upvote,
handle_set_factory_configs,
handle_set_payouts,
handle_social_profile_update,
Expand Down Expand Up @@ -426,6 +427,14 @@ async def handle_streamer_message(streamer_message: near_primitives.StreamerMess
args_dict, receiver_id, signer_id, receipt.receipt_id, now_datetime
)
break
case "remove_upvote":
logger.info(f"removing upvote... {args_dict}")
if receiver_id != LISTS_CONTRACT:
break
await handle_remove_upvote(
args_dict, receiver_id, signer_id
)
break
case "owner_add_admins":
logger.info(f"adding admins.. {args_dict}")
if not match_nadabot_registry_pattern(receiver_id):
Expand Down
19 changes: 18 additions & 1 deletion indexer_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ async def handle_list_upvote(
"created_at": created_at
}

list_obj = List.objects.get(on_chain_id=data.get("list_id"))
list_obj = await List.objects.aget(on_chain_id=data.get("list_id"))

await ListUpvote.objects.aupdate_or_create(
list=list_obj,
Expand All @@ -695,6 +695,23 @@ async def handle_list_upvote(
logger.error(f"Failed to upvote list, Error: {e}")



async def handle_remove_upvote(
data: dict, receiver_id: str, signer_id: str
):
try:

logger.info(f"remove upvote from list: {data}, {receiver_id}")
list_obj = await List.objects.aget(on_chain_id=data.get("list_id"))
await ListUpvote.objects.filter(list=list_obj, account_id=signer_id).adelete()

logger.info(
f"Upvote removed successfully"
)
except Exception as e:
logger.error(f"Failed to remove upvote from list, Error: {e}")


async def handle_set_payouts(data: dict, receiver_id: str, receipt: Receipt):
try:

Expand Down

0 comments on commit 40b60b8

Please sign in to comment.