mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-14 10:44:27 +00:00
Complete self-destruct support
This commit is contained in:
parent
5eb6157c1b
commit
c1231245a4
4 changed files with 61 additions and 3 deletions
4
Makefile
4
Makefile
|
@ -25,3 +25,7 @@ webfinger:
|
|||
.PHONY: move-to
|
||||
move-to:
|
||||
-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
|
||||
|
|
26
app/boxes.py
26
app/boxes.py
|
@ -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")
|
||||
|
||||
delete_id = allocate_outbox_id()
|
||||
# FIXME addressing
|
||||
delete = {
|
||||
"@context": ap.AS_EXTENDED_CTX,
|
||||
"id": outbox_object_id(delete_id),
|
||||
|
@ -405,6 +406,31 @@ async def send_move(
|
|||
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(
|
||||
db_session: AsyncSession,
|
||||
ap_type: str,
|
||||
|
|
|
@ -341,10 +341,16 @@ make account=username@domain.tld move-to
|
|||
|
||||
### 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.
|
||||
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
|
||||
|
||||
|
|
22
tasks.py
22
tasks.py
|
@ -271,6 +271,28 @@ def move_to(ctx, moved_to):
|
|||
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
|
||||
def yunohost_config(
|
||||
ctx,
|
||||
|
|
Loading…
Reference in a new issue