diff --git a/backend/indexer_gifts/actions/user.py b/backend/indexer_gifts/actions/user.py index db98344c..43110f8d 100644 --- a/backend/indexer_gifts/actions/user.py +++ b/backend/indexer_gifts/actions/user.py @@ -82,20 +82,18 @@ async def _sync_user_gifts( existing = self.gift_service.find(ug.name) if existing: - # If it was owned by someone else, record they lost it - if ( - existing.telegram_owner_id - and existing.telegram_owner_id != telegram_user_id - ): - lost_ownership_user_ids.add(existing.telegram_owner_id) - - self.gift_service.update_ownership( - slug=ug.name, - telegram_owner_id=telegram_user_id, - blockchain_address=existing.blockchain_address, - owner_address=existing.owner_address, - ) - updated_count += 1 + # Only update if ownership actually changed + if existing.telegram_owner_id != telegram_user_id: + if existing.telegram_owner_id: + lost_ownership_user_ids.add(existing.telegram_owner_id) + + self.gift_service.update_ownership( + slug=ug.name, + telegram_owner_id=telegram_user_id, + blockchain_address=existing.blockchain_address, + owner_address=existing.owner_address, + ) + updated_count += 1 else: # Ensure collection exists using in-memory cache collection_id = int(ug.gift_id)