lemmy/crates/apub/src/migrations.rs
Nutomic dd0ba10b44
Pleroma federation2 (#1855)
* Allow fetching person from Pleroma, including test case (ref #1461)

* Added test case for parsing community from apub json

- fixed a bug with objectid (de)serialization
- fixed a bug with outbox fetching (ref #1582)

* Added apub test for post

* Ignore errors when reading community outbox (fixes #1582)

* Dont fetch community outbox/moderators during tests

* added test for lemmy comment

* Added federation test for pleroma comment

* Added html2md crate to parse comment html from pleroma (fixes #1461)

* some fixes for update_apub_test_files.sh

* Add tests for ToApub, private message, remove update script

* Delete objects from db at the end of each test
2021-10-21 13:25:35 -04:00

50 lines
1.9 KiB
Rust

use crate::fetcher::{object_id::ObjectId, post_or_comment::PostOrComment};
use lemmy_apub_lib::values::PublicUrl;
use serde::{Deserialize, Serialize};
use url::Url;
/// Migrate comment.in_reply_to field from containing post and parent comment ID, to only containing
/// the direct parent (whether its a post or comment). This is for compatibility with Pleroma and
/// Smithereen.
/// [https://github.com/LemmyNet/lemmy/issues/1454]
///
/// v0.12: receive both, send old (compatible with v0.11)
/// v0.13 receive both, send new (compatible with v0.12+, incompatible with v0.11)
/// v0.14: only send and receive new, remove migration (compatible with v0.13+)
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(untagged)]
pub enum CommentInReplyToMigration {
Old(Vec<Url>),
New(ObjectId<PostOrComment>),
}
// Another migration we are doing is to handle all deletions and removals using Delete activity.
// This is because Remove is for removing an object from a collection, so using it that way doesn't
// really make sense. It is also a problem because we have a RemoveMod activity, which was awkward
// to handle together with removing posts etc.
//
// v0.11: send and receive mod removals as Remove
// v0.12: receive removals as Remove, send as Delete (compatible with v0.11)
// v0.13: send and receive mod removals as Delete (compatible with v0.12)
//
// For v0.13, delete [`UndoRemovePostCommentOrCommunity`], and don't handle object deletion in
// [`RemoveMod`] handler.
/// Migrate value of field `to` from single value to vec.
///
/// v0.14: send as single value, accept both
/// v0.15: send as vec, accept both
/// v0.16: send and accept only vec
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(untagged)]
pub enum PublicUrlMigration {
Old(PublicUrl),
New([PublicUrl; 1]),
}
impl PublicUrlMigration {
pub(crate) fn create() -> PublicUrlMigration {
PublicUrlMigration::Old(PublicUrl::Public)
}
}