diff --git a/indexer_app/handler.py b/indexer_app/handler.py index 98d8628..dad3401 100644 --- a/indexer_app/handler.py +++ b/indexer_app/handler.py @@ -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, @@ -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): diff --git a/indexer_app/utils.py b/indexer_app/utils.py index 0716ad9..bc34468 100644 --- a/indexer_app/utils.py +++ b/indexer_app/utils.py @@ -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, @@ -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: