Remove PublicUrlMigration

breaking-apub-changes
Felix Ableitner 2021-10-22 12:38:19 +02:00
parent dd53f44c4d
commit 779e48857d
14 changed files with 36 additions and 56 deletions

View File

@ -389,7 +389,6 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
test('Report a comment', async () => { test('Report a comment', async () => {
let betaCommunity = (await resolveBetaCommunity(beta)).community; let betaCommunity = (await resolveBetaCommunity(beta)).community;
console.log(betaCommunity);
let postRes = (await createPost(beta, betaCommunity.community.id)).post_view.post; let postRes = (await createPost(beta, betaCommunity.community.id)).post_view.post;
expect(postRes).toBeDefined(); expect(postRes).toBeDefined();
let commentRes = (await createComment(beta, postRes.id)).comment_view.comment; let commentRes = (await createComment(beta, postRes.id)).comment_view.comment;

View File

@ -11,7 +11,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{ objects::{
comment::{ApubComment, Note}, comment::{ApubComment, Note},
community::ApubCommunity, community::ApubCommunity,
@ -23,6 +22,7 @@ use lemmy_api_common::{blocking, check_post_deleted_or_removed};
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType, FromApub, ToApub}, traits::{ActivityFields, ActivityHandler, ActorType, FromApub, ToApub},
values::PublicUrl,
verify::verify_domains_match, verify::verify_domains_match,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
@ -38,7 +38,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CreateOrUpdateComment { pub struct CreateOrUpdateComment {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
object: Note, object: Note,
cc: Vec<Url>, cc: Vec<Url>,
tag: Vec<Mention>, tag: Vec<Mention>,
@ -76,7 +76,7 @@ impl CreateOrUpdateComment {
let create_or_update = CreateOrUpdateComment { let create_or_update = CreateOrUpdateComment {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: comment.to_apub(context.pool()).await?, object: comment.to_apub(context.pool()).await?,
cc: maa.ccs, cc: maa.ccs,
tag: maa.tags, tag: maa.tags,

View File

@ -10,7 +10,6 @@ use crate::{
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
generate_moderators_url, generate_moderators_url,
migrations::PublicUrlMigration,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
}; };
use activitystreams::{ use activitystreams::{
@ -23,6 +22,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
source::community::{CommunityModerator, CommunityModeratorForm}, source::community::{CommunityModerator, CommunityModeratorForm},
@ -37,7 +37,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct AddMod { pub struct AddMod {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
object: ObjectId<ApubPerson>, object: ObjectId<ApubPerson>,
target: Url, target: Url,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
@ -63,7 +63,7 @@ impl AddMod {
)?; )?;
let add = AddMod { let add = AddMod {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: ObjectId::new(added_mod.actor_id()), object: ObjectId::new(added_mod.actor_id()),
target: generate_moderators_url(&community.actor_id)?.into(), target: generate_moderators_url(&community.actor_id)?.into(),
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],

View File

@ -20,7 +20,6 @@ use crate::{
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
http::is_activity_already_known, http::is_activity_already_known,
insert_activity, insert_activity,
migrations::PublicUrlMigration,
objects::community::ApubCommunity, objects::community::ApubCommunity,
send_lemmy_activity, send_lemmy_activity,
CommunityType, CommunityType,
@ -34,6 +33,7 @@ use activitystreams::{
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
}; };
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
@ -61,7 +61,7 @@ pub enum AnnouncableActivities {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct AnnounceActivity { pub struct AnnounceActivity {
actor: ObjectId<ApubCommunity>, actor: ObjectId<ApubCommunity>,
to: PublicUrlMigration, to: [PublicUrl; 1],
object: AnnouncableActivities, object: AnnouncableActivities,
cc: Vec<Url>, cc: Vec<Url>,
#[serde(rename = "type")] #[serde(rename = "type")]
@ -82,7 +82,7 @@ impl AnnounceActivity {
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
let announce = AnnounceActivity { let announce = AnnounceActivity {
actor: ObjectId::new(community.actor_id()), actor: ObjectId::new(community.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object, object,
cc: vec![community.followers_url()], cc: vec![community.followers_url()],
kind: AnnounceType::Announce, kind: AnnounceType::Announce,

View File

@ -8,7 +8,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
}; };
use activitystreams::{ use activitystreams::{
@ -21,6 +20,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
source::community::{ source::community::{
@ -40,7 +40,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct BlockUserFromCommunity { pub struct BlockUserFromCommunity {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
pub(in crate::activities::community) object: ObjectId<ApubPerson>, pub(in crate::activities::community) object: ObjectId<ApubPerson>,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
#[serde(rename = "type")] #[serde(rename = "type")]
@ -61,7 +61,7 @@ impl BlockUserFromCommunity {
) -> Result<BlockUserFromCommunity, LemmyError> { ) -> Result<BlockUserFromCommunity, LemmyError> {
Ok(BlockUserFromCommunity { Ok(BlockUserFromCommunity {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: ObjectId::new(target.actor_id()), object: ObjectId::new(target.actor_id()),
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],
kind: BlockType::Block, kind: BlockType::Block,

View File

@ -10,7 +10,6 @@ use crate::{
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
generate_moderators_url, generate_moderators_url,
migrations::PublicUrlMigration,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
}; };
use activitystreams::{ use activitystreams::{
@ -23,6 +22,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
source::community::{CommunityModerator, CommunityModeratorForm}, source::community::{CommunityModerator, CommunityModeratorForm},
@ -37,7 +37,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct RemoveMod { pub struct RemoveMod {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
pub(in crate::activities) object: ObjectId<ApubPerson>, pub(in crate::activities) object: ObjectId<ApubPerson>,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
#[serde(rename = "type")] #[serde(rename = "type")]
@ -64,7 +64,7 @@ impl RemoveMod {
)?; )?;
let remove = RemoveMod { let remove = RemoveMod {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: ObjectId::new(removed_mod.actor_id()), object: ObjectId::new(removed_mod.actor_id()),
target: generate_moderators_url(&community.actor_id)?.into(), target: generate_moderators_url(&community.actor_id)?.into(),
id: id.clone(), id: id.clone(),

View File

@ -12,7 +12,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
}; };
use activitystreams::{ use activitystreams::{
@ -25,6 +24,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
source::community::{CommunityPersonBan, CommunityPersonBanForm}, source::community::{CommunityPersonBan, CommunityPersonBanForm},
@ -39,7 +39,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UndoBlockUserFromCommunity { pub struct UndoBlockUserFromCommunity {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
object: BlockUserFromCommunity, object: BlockUserFromCommunity,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
#[serde(rename = "type")] #[serde(rename = "type")]
@ -66,7 +66,7 @@ impl UndoBlockUserFromCommunity {
)?; )?;
let undo = UndoBlockUserFromCommunity { let undo = UndoBlockUserFromCommunity {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: block, object: block,
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],
kind: UndoType::Undo, kind: UndoType::Undo,

View File

@ -8,7 +8,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{ objects::{
community::{ApubCommunity, Group}, community::{ApubCommunity, Group},
person::ApubPerson, person::ApubPerson,
@ -24,6 +23,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType, ToApub}, traits::{ActivityFields, ActivityHandler, ActorType, ToApub},
values::PublicUrl,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
source::community::{Community, CommunityForm}, source::community::{Community, CommunityForm},
@ -40,7 +40,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UpdateCommunity { pub struct UpdateCommunity {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
// TODO: would be nice to use a separate struct here, which only contains the fields updated here // TODO: would be nice to use a separate struct here, which only contains the fields updated here
object: Group, object: Group,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
@ -65,7 +65,7 @@ impl UpdateCommunity {
)?; )?;
let update = UpdateCommunity { let update = UpdateCommunity {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: community.to_apub(context.pool()).await?, object: community.to_apub(context.pool()).await?,
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],
kind: UpdateType::Update, kind: UpdateType::Update,

View File

@ -12,7 +12,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
}; };
use activitystreams::{ use activitystreams::{
@ -26,6 +25,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
}; };
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{ source::{
@ -66,7 +66,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Delete { pub struct Delete {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
pub(in crate::activities::deletion) object: Url, pub(in crate::activities::deletion) object: Url,
pub(in crate::activities::deletion) cc: [ObjectId<ApubCommunity>; 1], pub(in crate::activities::deletion) cc: [ObjectId<ApubCommunity>; 1],
#[serde(rename = "type")] #[serde(rename = "type")]
@ -144,7 +144,7 @@ impl Delete {
) -> Result<Delete, LemmyError> { ) -> Result<Delete, LemmyError> {
Ok(Delete { Ok(Delete {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: object_id, object: object_id,
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],
kind: DeleteType::Delete, kind: DeleteType::Delete,

View File

@ -13,7 +13,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
}; };
use activitystreams::{ use activitystreams::{
@ -27,6 +26,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
}; };
use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post}; use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post};
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
@ -42,7 +42,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UndoDelete { pub struct UndoDelete {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
object: Delete, object: Delete,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
#[serde(rename = "type")] #[serde(rename = "type")]
@ -117,7 +117,7 @@ impl UndoDelete {
)?; )?;
let undo = UndoDelete { let undo = UndoDelete {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object, object,
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],
kind: UndoType::Undo, kind: UndoType::Undo,

View File

@ -10,7 +10,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{ objects::{
community::ApubCommunity, community::ApubCommunity,
person::ApubPerson, person::ApubPerson,
@ -23,6 +22,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType, FromApub, ToApub}, traits::{ActivityFields, ActivityHandler, ActorType, FromApub, ToApub},
values::PublicUrl,
verify::{verify_domains_match, verify_urls_match}, verify::{verify_domains_match, verify_urls_match},
}; };
use lemmy_db_schema::{source::community::Community, traits::Crud}; use lemmy_db_schema::{source::community::Community, traits::Crud};
@ -35,7 +35,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CreateOrUpdatePost { pub struct CreateOrUpdatePost {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
object: Page, object: Page,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
#[serde(rename = "type")] #[serde(rename = "type")]
@ -67,7 +67,7 @@ impl CreateOrUpdatePost {
)?; )?;
let create_or_update = CreateOrUpdatePost { let create_or_update = CreateOrUpdatePost {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: post.to_apub(context.pool()).await?, object: post.to_apub(context.pool()).await?,
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],
kind, kind,

View File

@ -12,7 +12,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
PostOrComment, PostOrComment,
}; };
@ -26,6 +25,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
verify::verify_urls_match, verify::verify_urls_match,
}; };
use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud}; use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud};
@ -39,7 +39,7 @@ use url::Url;
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct UndoVote { pub struct UndoVote {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
object: Vote, object: Vote,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
#[serde(rename = "type")] #[serde(rename = "type")]
@ -72,7 +72,7 @@ impl UndoVote {
)?; )?;
let undo_vote = UndoVote { let undo_vote = UndoVote {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object, object,
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],
kind: UndoType::Undo, kind: UndoType::Undo,

View File

@ -8,7 +8,6 @@ use crate::{
}, },
context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::PublicUrlMigration,
objects::{community::ApubCommunity, person::ApubPerson}, objects::{community::ApubCommunity, person::ApubPerson},
PostOrComment, PostOrComment,
}; };
@ -18,6 +17,7 @@ use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler, ActorType}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl,
}; };
use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud}; use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud};
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
@ -58,7 +58,7 @@ impl From<&VoteType> for i16 {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Vote { pub struct Vote {
actor: ObjectId<ApubPerson>, actor: ObjectId<ApubPerson>,
to: PublicUrlMigration, to: [PublicUrl; 1],
pub(in crate::activities::voting) object: ObjectId<PostOrComment>, pub(in crate::activities::voting) object: ObjectId<PostOrComment>,
cc: [ObjectId<ApubCommunity>; 1], cc: [ObjectId<ApubCommunity>; 1],
#[serde(rename = "type")] #[serde(rename = "type")]
@ -80,7 +80,7 @@ impl Vote {
) -> Result<Vote, LemmyError> { ) -> Result<Vote, LemmyError> {
Ok(Vote { Ok(Vote {
actor: ObjectId::new(actor.actor_id()), actor: ObjectId::new(actor.actor_id()),
to: PublicUrlMigration::create(), to: [PublicUrl::Public],
object: ObjectId::new(object.ap_id()), object: ObjectId::new(object.ap_id()),
cc: [ObjectId::new(community.actor_id())], cc: [ObjectId::new(community.actor_id())],
kind: kind.clone(), kind: kind.clone(),

View File

@ -1,20 +1 @@
use lemmy_apub_lib::values::PublicUrl;
use serde::{Deserialize, Serialize};
/// 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)
}
}