mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +00:00
Remove PublicUrlMigration
This commit is contained in:
parent
dd53f44c4d
commit
779e48857d
14 changed files with 36 additions and 56 deletions
|
@ -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 () => {
|
||||
let betaCommunity = (await resolveBetaCommunity(beta)).community;
|
||||
console.log(betaCommunity);
|
||||
let postRes = (await createPost(beta, betaCommunity.community.id)).post_view.post;
|
||||
expect(postRes).toBeDefined();
|
||||
let commentRes = (await createComment(beta, postRes.id)).comment_view.comment;
|
||||
|
|
|
@ -11,7 +11,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{
|
||||
comment::{ApubComment, Note},
|
||||
community::ApubCommunity,
|
||||
|
@ -23,6 +22,7 @@ use lemmy_api_common::{blocking, check_post_deleted_or_removed};
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType, FromApub, ToApub},
|
||||
values::PublicUrl,
|
||||
verify::verify_domains_match,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
@ -38,7 +38,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateOrUpdateComment {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
object: Note,
|
||||
cc: Vec<Url>,
|
||||
tag: Vec<Mention>,
|
||||
|
@ -76,7 +76,7 @@ impl CreateOrUpdateComment {
|
|||
|
||||
let create_or_update = CreateOrUpdateComment {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: comment.to_apub(context.pool()).await?,
|
||||
cc: maa.ccs,
|
||||
tag: maa.tags,
|
||||
|
|
|
@ -10,7 +10,6 @@ use crate::{
|
|||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
generate_moderators_url,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{
|
||||
|
@ -23,6 +22,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{CommunityModerator, CommunityModeratorForm},
|
||||
|
@ -37,7 +37,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AddMod {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
object: ObjectId<ApubPerson>,
|
||||
target: Url,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
|
@ -63,7 +63,7 @@ impl AddMod {
|
|||
)?;
|
||||
let add = AddMod {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: ObjectId::new(added_mod.actor_id()),
|
||||
target: generate_moderators_url(&community.actor_id)?.into(),
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
|
|
|
@ -20,7 +20,6 @@ use crate::{
|
|||
fetcher::object_id::ObjectId,
|
||||
http::is_activity_already_known,
|
||||
insert_activity,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::community::ApubCommunity,
|
||||
send_lemmy_activity,
|
||||
CommunityType,
|
||||
|
@ -34,6 +33,7 @@ use activitystreams::{
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_utils::LemmyError;
|
||||
use lemmy_websocket::LemmyContext;
|
||||
|
@ -61,7 +61,7 @@ pub enum AnnouncableActivities {
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AnnounceActivity {
|
||||
actor: ObjectId<ApubCommunity>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
object: AnnouncableActivities,
|
||||
cc: Vec<Url>,
|
||||
#[serde(rename = "type")]
|
||||
|
@ -82,7 +82,7 @@ impl AnnounceActivity {
|
|||
) -> Result<(), LemmyError> {
|
||||
let announce = AnnounceActivity {
|
||||
actor: ObjectId::new(community.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object,
|
||||
cc: vec![community.followers_url()],
|
||||
kind: AnnounceType::Announce,
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{
|
||||
|
@ -21,6 +20,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{
|
||||
|
@ -40,7 +40,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct BlockUserFromCommunity {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
pub(in crate::activities::community) object: ObjectId<ApubPerson>,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
#[serde(rename = "type")]
|
||||
|
@ -61,7 +61,7 @@ impl BlockUserFromCommunity {
|
|||
) -> Result<BlockUserFromCommunity, LemmyError> {
|
||||
Ok(BlockUserFromCommunity {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: ObjectId::new(target.actor_id()),
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
kind: BlockType::Block,
|
||||
|
|
|
@ -10,7 +10,6 @@ use crate::{
|
|||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
generate_moderators_url,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{
|
||||
|
@ -23,6 +22,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{CommunityModerator, CommunityModeratorForm},
|
||||
|
@ -37,7 +37,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RemoveMod {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
pub(in crate::activities) object: ObjectId<ApubPerson>,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
#[serde(rename = "type")]
|
||||
|
@ -64,7 +64,7 @@ impl RemoveMod {
|
|||
)?;
|
||||
let remove = RemoveMod {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: ObjectId::new(removed_mod.actor_id()),
|
||||
target: generate_moderators_url(&community.actor_id)?.into(),
|
||||
id: id.clone(),
|
||||
|
|
|
@ -12,7 +12,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{
|
||||
|
@ -25,6 +24,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{CommunityPersonBan, CommunityPersonBanForm},
|
||||
|
@ -39,7 +39,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoBlockUserFromCommunity {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
object: BlockUserFromCommunity,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
#[serde(rename = "type")]
|
||||
|
@ -66,7 +66,7 @@ impl UndoBlockUserFromCommunity {
|
|||
)?;
|
||||
let undo = UndoBlockUserFromCommunity {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: block,
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
kind: UndoType::Undo,
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{
|
||||
community::{ApubCommunity, Group},
|
||||
person::ApubPerson,
|
||||
|
@ -24,6 +23,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType, ToApub},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::community::{Community, CommunityForm},
|
||||
|
@ -40,7 +40,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UpdateCommunity {
|
||||
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
|
||||
object: Group,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
|
@ -65,7 +65,7 @@ impl UpdateCommunity {
|
|||
)?;
|
||||
let update = UpdateCommunity {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: community.to_apub(context.pool()).await?,
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
kind: UpdateType::Update,
|
||||
|
|
|
@ -12,7 +12,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{
|
||||
|
@ -26,6 +25,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -66,7 +66,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Delete {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
pub(in crate::activities::deletion) object: Url,
|
||||
pub(in crate::activities::deletion) cc: [ObjectId<ApubCommunity>; 1],
|
||||
#[serde(rename = "type")]
|
||||
|
@ -144,7 +144,7 @@ impl Delete {
|
|||
) -> Result<Delete, LemmyError> {
|
||||
Ok(Delete {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: object_id,
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
kind: DeleteType::Delete,
|
||||
|
|
|
@ -13,7 +13,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
};
|
||||
use activitystreams::{
|
||||
|
@ -27,6 +26,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post};
|
||||
use lemmy_utils::LemmyError;
|
||||
|
@ -42,7 +42,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoDelete {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
object: Delete,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
#[serde(rename = "type")]
|
||||
|
@ -117,7 +117,7 @@ impl UndoDelete {
|
|||
)?;
|
||||
let undo = UndoDelete {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object,
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
kind: UndoType::Undo,
|
||||
|
|
|
@ -10,7 +10,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{
|
||||
community::ApubCommunity,
|
||||
person::ApubPerson,
|
||||
|
@ -23,6 +22,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType, FromApub, ToApub},
|
||||
values::PublicUrl,
|
||||
verify::{verify_domains_match, verify_urls_match},
|
||||
};
|
||||
use lemmy_db_schema::{source::community::Community, traits::Crud};
|
||||
|
@ -35,7 +35,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CreateOrUpdatePost {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
object: Page,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
#[serde(rename = "type")]
|
||||
|
@ -67,7 +67,7 @@ impl CreateOrUpdatePost {
|
|||
)?;
|
||||
let create_or_update = CreateOrUpdatePost {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: post.to_apub(context.pool()).await?,
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
kind,
|
||||
|
|
|
@ -12,7 +12,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
PostOrComment,
|
||||
};
|
||||
|
@ -26,6 +25,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
verify::verify_urls_match,
|
||||
};
|
||||
use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud};
|
||||
|
@ -39,7 +39,7 @@ use url::Url;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct UndoVote {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
object: Vote,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
#[serde(rename = "type")]
|
||||
|
@ -72,7 +72,7 @@ impl UndoVote {
|
|||
)?;
|
||||
let undo_vote = UndoVote {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object,
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
kind: UndoType::Undo,
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::{
|
|||
},
|
||||
context::lemmy_context,
|
||||
fetcher::object_id::ObjectId,
|
||||
migrations::PublicUrlMigration,
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
PostOrComment,
|
||||
};
|
||||
|
@ -18,6 +17,7 @@ use lemmy_api_common::blocking;
|
|||
use lemmy_apub_lib::{
|
||||
data::Data,
|
||||
traits::{ActivityFields, ActivityHandler, ActorType},
|
||||
values::PublicUrl,
|
||||
};
|
||||
use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud};
|
||||
use lemmy_utils::LemmyError;
|
||||
|
@ -58,7 +58,7 @@ impl From<&VoteType> for i16 {
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Vote {
|
||||
actor: ObjectId<ApubPerson>,
|
||||
to: PublicUrlMigration,
|
||||
to: [PublicUrl; 1],
|
||||
pub(in crate::activities::voting) object: ObjectId<PostOrComment>,
|
||||
cc: [ObjectId<ApubCommunity>; 1],
|
||||
#[serde(rename = "type")]
|
||||
|
@ -80,7 +80,7 @@ impl Vote {
|
|||
) -> Result<Vote, LemmyError> {
|
||||
Ok(Vote {
|
||||
actor: ObjectId::new(actor.actor_id()),
|
||||
to: PublicUrlMigration::create(),
|
||||
to: [PublicUrl::Public],
|
||||
object: ObjectId::new(object.ap_id()),
|
||||
cc: [ObjectId::new(community.actor_id())],
|
||||
kind: kind.clone(),
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue