Change public activities to field to array

This commit is contained in:
Felix Ableitner 2021-08-27 22:40:05 +02:00
parent 2c8003a9fa
commit bf759e1623
13 changed files with 25 additions and 25 deletions

View file

@ -27,7 +27,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct CreateOrUpdateComment {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
object: Note,
cc: Vec<Url>,
tag: Vec<Mention>,
@ -61,7 +61,7 @@ impl CreateOrUpdateComment {
let create_or_update = CreateOrUpdateComment {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: comment.to_apub(context.pool()).await?,
cc: maa.ccs,
tag: maa.tags,

View file

@ -35,7 +35,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct AddMod {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
object: Url,
target: Url,
cc: [Url; 1],
@ -58,7 +58,7 @@ impl AddMod {
let id = generate_activity_id(AddType::Add)?;
let add = AddMod {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: added_mod.actor_id(),
target: generate_moderators_url(&community.actor_id)?.into(),
cc: [community.actor_id()],

View file

@ -58,7 +58,7 @@ pub enum AnnouncableActivities {
#[serde(rename_all = "camelCase")]
pub struct AnnounceActivity {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
object: AnnouncableActivities,
cc: Vec<Url>,
#[serde(rename = "type")]
@ -79,7 +79,7 @@ impl AnnounceActivity {
) -> Result<(), LemmyError> {
let announce = AnnounceActivity {
actor: community.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object,
cc: vec![community.followers_url()],
kind: AnnounceType::Announce,

View file

@ -39,7 +39,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct BlockUserFromCommunity {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
pub(in crate::activities::community) object: Url,
cc: [Url; 1],
#[serde(rename = "type")]
@ -59,7 +59,7 @@ impl BlockUserFromCommunity {
) -> Result<BlockUserFromCommunity, LemmyError> {
Ok(BlockUserFromCommunity {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: target.actor_id(),
cc: [community.actor_id()],
kind: BlockType::Block,

View file

@ -36,7 +36,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct RemoveMod {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
pub(in crate::activities) object: Url,
cc: [Url; 1],
#[serde(rename = "type")]
@ -60,7 +60,7 @@ impl RemoveMod {
let id = generate_activity_id(RemoveType::Remove)?;
let remove = RemoveMod {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: removed_mod.actor_id(),
target: Some(generate_moderators_url(&community.actor_id)?.into()),
id: id.clone(),

View file

@ -33,7 +33,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct UndoBlockUserFromCommunity {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
object: BlockUserFromCommunity,
cc: [Url; 1],
#[serde(rename = "type")]
@ -57,7 +57,7 @@ impl UndoBlockUserFromCommunity {
let id = generate_activity_id(UndoType::Undo)?;
let undo = UndoBlockUserFromCommunity {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: block,
cc: [community.actor_id()],
kind: UndoType::Undo,

View file

@ -35,7 +35,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct UpdateCommunity {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
// TODO: would be nice to use a separate struct here, which only contains the fields updated here
object: Group,
cc: [Url; 1],
@ -57,7 +57,7 @@ impl UpdateCommunity {
let id = generate_activity_id(UpdateType::Update)?;
let update = UpdateCommunity {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: community.to_apub(context.pool()).await?,
cc: [community.actor_id()],
kind: UpdateType::Update,

View file

@ -63,7 +63,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct Delete {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
pub(in crate::activities::deletion) object: Url,
pub(in crate::activities::deletion) cc: [Url; 1],
#[serde(rename = "type")]
@ -139,7 +139,7 @@ impl Delete {
) -> Result<Delete, LemmyError> {
Ok(Delete {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: object_id,
cc: [community.actor_id()],
kind: DeleteType::Delete,

View file

@ -39,7 +39,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct UndoDelete {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
object: Delete,
cc: [Url; 1],
#[serde(rename = "type")]
@ -110,7 +110,7 @@ impl UndoDelete {
let id = generate_activity_id(UndoType::Undo)?;
let undo = UndoDelete {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object,
cc: [community.actor_id()],
kind: UndoType::Undo,

View file

@ -35,7 +35,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct CreateOrUpdatePost {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
object: Page,
cc: [Url; 1],
#[serde(rename = "type")]
@ -63,7 +63,7 @@ impl CreateOrUpdatePost {
let id = generate_activity_id(kind.clone())?;
let create_or_update = CreateOrUpdatePost {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: post.to_apub(context.pool()).await?,
cc: [community.actor_id()],
kind,

View file

@ -19,7 +19,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct UndoRemovePostCommentOrCommunity {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
// Note, there is no such thing as Undo/Remove/Mod, so we ignore that
object: RemoveMod,
cc: [Url; 1],

View file

@ -42,7 +42,7 @@ use url::Url;
#[serde(rename_all = "camelCase")]
pub struct UndoVote {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
object: Vote,
cc: [Url; 1],
#[serde(rename = "type")]
@ -71,7 +71,7 @@ impl UndoVote {
let id = generate_activity_id(UndoType::Undo)?;
let undo_vote = UndoVote {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object,
cc: [community.actor_id()],
kind: UndoType::Undo,

View file

@ -62,7 +62,7 @@ impl From<&VoteType> for i16 {
#[serde(rename_all = "camelCase")]
pub struct Vote {
actor: Url,
to: PublicUrl,
to: [PublicUrl; 1],
pub(in crate::activities::voting) object: Url,
cc: [Url; 1],
#[serde(rename = "type")]
@ -83,7 +83,7 @@ impl Vote {
) -> Result<Vote, LemmyError> {
Ok(Vote {
actor: actor.actor_id(),
to: PublicUrl::Public,
to: [PublicUrl::Public],
object: object.ap_id(),
cc: [community.actor_id()],
kind: kind.clone(),