Split activity table into sent and received parts (fixes #3103) (#3583)
authorNutomic <me@nutomic.com>
Fri, 14 Jul 2023 15:17:06 +0000 (17:17 +0200)
committerGitHub <noreply@github.com>
Fri, 14 Jul 2023 15:17:06 +0000 (11:17 -0400)
commite9e76549a88cfbdab36f00d302cceabcaaa24f4c
treee325900a4d6ea4772fff1138abd197f5b7b3a7d0
parent2938b50908fb44c2f4dda61365ac7257021bf3c0
Split activity table into sent and received parts (fixes #3103) (#3583)

* Split activity table into sent and received parts (fixes #3103)

The received activities are only stored in order to avoid processing
the same incoming activity multiple times. For this purpose it is
completely unnecessary to store the data. So we can split the
table into sent_activity and received_activity parts, where
only sent_activity table needs to store activity data. This should
reduce storage use significantly.

Also reduces activity storage duration to three months, we can reduce
this further if necessary.

Additionally the id columns of activity tables are removed because
they are completely unused and risk overflowing (fixes #3560).

* address review

* move insert_received_activity() methods to verify handlers

* remove unnecessary conflict line

* clippy

* use on conflict, add tests
28 files changed:
crates/apub/src/activities/block/block_user.rs
crates/apub/src/activities/block/undo_block_user.rs
crates/apub/src/activities/community/announce.rs
crates/apub/src/activities/community/collection_add.rs
crates/apub/src/activities/community/collection_remove.rs
crates/apub/src/activities/community/lock_page.rs
crates/apub/src/activities/community/report.rs
crates/apub/src/activities/community/update.rs
crates/apub/src/activities/create_or_update/comment.rs
crates/apub/src/activities/create_or_update/post.rs
crates/apub/src/activities/create_or_update/private_message.rs
crates/apub/src/activities/deletion/delete.rs
crates/apub/src/activities/deletion/delete_user.rs
crates/apub/src/activities/deletion/undo_delete.rs
crates/apub/src/activities/following/accept.rs
crates/apub/src/activities/following/follow.rs
crates/apub/src/activities/following/undo_follow.rs
crates/apub/src/activities/mod.rs
crates/apub/src/activities/voting/undo_vote.rs
crates/apub/src/activities/voting/vote.rs
crates/apub/src/http/mod.rs
crates/apub/src/lib.rs
crates/db_schema/src/impls/activity.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/activity.rs
migrations/2023-07-11-084714_receive_activity_table/down.sql [new file with mode: 0644]
migrations/2023-07-11-084714_receive_activity_table/up.sql [new file with mode: 0644]
src/scheduled_tasks.rs