Complete self-destruct support

This commit is contained in:
Thomas Sileo 2022-09-11 10:51:08 +02:00
parent 5eb6157c1b
commit c1231245a4
4 changed files with 61 additions and 3 deletions

View file

@ -25,3 +25,7 @@ webfinger:
.PHONY: move-to .PHONY: move-to
move-to: move-to:
-docker run --volume `pwd`/data:/app/data --volume `pwd`/app/static:/app/app/static microblogpub/microblogpub inv move-to $(account) -docker run --volume `pwd`/data:/app/data --volume `pwd`/app/static:/app/app/static microblogpub/microblogpub inv move-to $(account)
.PHONY: self-destruct
move-to:
-docker run --volume `pwd`/data:/app/data --volume `pwd`/app/static:/app/app/static microblogpub/microblogpub inv self-destruct

View file

@ -94,6 +94,7 @@ async def send_delete(db_session: AsyncSession, ap_object_id: str) -> None:
raise ValueError(f"{ap_object_id} not found in the outbox") raise ValueError(f"{ap_object_id} not found in the outbox")
delete_id = allocate_outbox_id() delete_id = allocate_outbox_id()
# FIXME addressing
delete = { delete = {
"@context": ap.AS_EXTENDED_CTX, "@context": ap.AS_EXTENDED_CTX,
"id": outbox_object_id(delete_id), "id": outbox_object_id(delete_id),
@ -405,6 +406,31 @@ async def send_move(
await db_session.commit() await db_session.commit()
async def send_self_destruct(db_session: AsyncSession) -> None:
delete_id = allocate_outbox_id()
delete = {
"@context": ap.AS_EXTENDED_CTX,
"id": outbox_object_id(delete_id),
"type": "Delete",
"actor": ID,
"object": ID,
"to": [ap.AS_PUBLIC],
}
outbox_object = await save_outbox_object(
db_session,
delete_id,
delete,
)
if not outbox_object.id:
raise ValueError("Should never happen")
recipients = await compute_all_known_recipients(db_session)
for rcp in recipients:
await new_outgoing_activity(db_session, rcp, outbox_object.id)
await db_session.commit()
async def send_create( async def send_create(
db_session: AsyncSession, db_session: AsyncSession,
ap_type: str, ap_type: str,

View file

@ -341,10 +341,16 @@ make account=username@domain.tld move-to
### Deleting the instance ### Deleting the instance
**This section is just a draft.**
You want to delete your instance, you can request other instances to delete your remote profile. You want to delete your instance, you can request other instances to delete your remote profile.
Once deleted, you won't be able to use your instance anymore.
Note that this is a best-effort delete as some instances may not delete your data.
The command won't remove any local data, it just broadcast account deletion messages to all known servers.
After executing the command, you should let the server run until all the outgoing delete tasks are sent.
Once deleted, you won't be able to use your instance anymore, but you will be able to perform a fresh re-install of any ActivityPub software.
#### Python edition #### Python edition

View file

@ -271,6 +271,28 @@ def move_to(ctx, moved_to):
asyncio.run(_send_move()) asyncio.run(_send_move())
@task
def self_destruct(ctx):
# type: (Context) -> None
from loguru import logger
from app.boxes import send_self_destruct
from app.database import async_session
logger.disable("app")
async def _send_self_destruct():
if input("Initiating self destruct, type yes to confirm: ") != "yes":
print("Aborting")
async with async_session() as db_session:
await send_self_destruct(db_session)
print("Done")
asyncio.run(_send_self_destruct())
@task @task
def yunohost_config( def yunohost_config(
ctx, ctx,