Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install_requires =
aiohttp==3.8.1
aioipfs@git+https://github.com/aleph-im/aioipfs.git@76d5624661e879a13b70f3ea87dc9c9604c7eda7
aleph-client==0.4.6
aleph-message==0.1.18
aleph-message==0.1.19
coincurve==15.0.1
configmanager==1.35.1
configparser==5.2.0
Expand Down
19 changes: 15 additions & 4 deletions src/aleph/handlers/forget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from aleph.utils import item_type_from_hash


logger = logging.getLogger(__name__)


@dataclass
class TargetMessageInfo:
item_hash: str
Expand Down Expand Up @@ -45,9 +48,6 @@ def from_db_object(cls, message_dict: Dict) -> TargetMessageInfo:
)


logger = logging.getLogger(__name__)


async def count_file_references(storage_hash: str) -> int:
"""Count the number of references to a file on Aleph."""
logger.debug(f"Counting documents for {storage_hash}")
Expand Down Expand Up @@ -214,8 +214,19 @@ async def handle_forget_message(message: Dict, content: Dict):
# Parsing and validation
forget_message = ForgetMessage(**message, content=content)
logger.debug(f"Handling forget message {forget_message.item_hash}")
hashes_to_forget = forget_message.content.hashes

for target_aggregate in forget_message.content.aggregates:
aggregate_hashes = (
message["item_hash"]
async for message in Message.collection.find(
{"type": MessageType.aggregate.value, "content.key": target_aggregate},
projection={"_id": 0, "item_hash": 1},
)
)
hashes_to_forget.extend(aggregate_hashes)

for target_hash in forget_message.content.hashes:
for target_hash in hashes_to_forget:
target_info = await get_target_message_info(target_hash)

if target_info is None:
Expand Down