diff options
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | server/Cargo.lock | 5 | ||||
-rw-r--r-- | server/Cargo.toml | 10 | ||||
-rw-r--r-- | server/src/activitypub/activity.rs | 1496 | ||||
-rw-r--r-- | server/src/activitypub/actor/mod.rs | 291 | ||||
-rw-r--r-- | server/src/activitypub/actor/properties.rs | 129 | ||||
-rw-r--r-- | server/src/activitypub/collection.rs | 264 | ||||
-rw-r--r-- | server/src/activitypub/endpoint.rs | 107 | ||||
-rw-r--r-- | server/src/activitypub/link.rs | 23 | ||||
-rw-r--r-- | server/src/activitypub/mod.rs | 57 | ||||
-rw-r--r-- | server/src/activitypub/object/mod.rs | 444 | ||||
-rw-r--r-- | server/src/activitypub/object/properties.rs | 111 | ||||
-rw-r--r-- | server/src/apub/community.rs | 2 | ||||
-rw-r--r-- | server/src/apub/post.rs | 2 | ||||
-rw-r--r-- | server/src/apub/puller.rs | 2 | ||||
-rw-r--r-- | server/src/apub/user.rs | 2 | ||||
-rw-r--r-- | server/src/lib.rs | 1 |
17 files changed, 5 insertions, 2947 deletions
@@ -165,9 +165,3 @@ ts-node translation_report.ts ## Credits Logo made by Andy Cuccaro (@andycuccaro) under the CC-BY-SA 4.0 license. - -## License - -All code is licensed under AGPLv3 unless otherwise indicated. - -The code in `server/src/activitypub` is taken from the [Aardwolf/activitypub](https://crates.io/crates/activitypub) crate and licensed under GPLv3. diff --git a/server/Cargo.lock b/server/Cargo.lock index 242fa789..12531920 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -1493,15 +1493,11 @@ name = "lemmy_server" version = "0.0.1" dependencies = [ "activitypub 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "activitystreams-derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "activitystreams-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "activitystreams-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-files 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "actix-rt 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-web-actors 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", "bcrypt 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1521,7 +1517,6 @@ dependencies = [ "reqwest 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)", "rss 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "strum 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/server/Cargo.toml b/server/Cargo.toml index 1b6ea305..82823057 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -13,7 +13,6 @@ activitypub = "0.2.0" chrono = { version = "0.4.7", features = ["serde"] } failure = "0.1.5" serde_json = { version = "1.0.45", features = ["preserve_order"]} -serde_derive = "1.0" serde = { version = "1.0.94", features = ["derive"] } actix = "0.9.0" actix-web = "2.0.0" @@ -34,11 +33,4 @@ rss = "1.9.0" htmlescape = "0.3.1" config = "0.10.1" hjson = "0.8.2" -reqwest = "0.9.24" -activitystreams-derive = "0.2" -activitystreams-traits = "0.2" -activitystreams-types = "0.3" - - -[dev-dependencies] -anyhow = "1.0" +reqwest = "0.9.24"
\ No newline at end of file diff --git a/server/src/activitypub/activity.rs b/server/src/activitypub/activity.rs deleted file mode 100644 index c92b6eaf..00000000 --- a/server/src/activitypub/activity.rs +++ /dev/null @@ -1,1496 +0,0 @@ -/* - * This file is part of ActivityPub. - * - * Copyright © 2018 Riley Trautman - * - * ActivityPub is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ActivityPub is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ActivityPub. If not, see <http://www.gnu.org/licenses/>. - */ - -//! Activity traits and types - -pub use activitystreams_traits::{Activity, IntransitiveActivity}; -pub use activitystreams_types::activity::{kind, properties, ActivityExt}; -use serde_derive::{Deserialize, Serialize}; - -use self::{kind::*, properties::*}; -use activitypub::object::{ - properties::{ApObjectProperties, ObjectProperties}, - ApObjectExt, Object, ObjectExt, -}; - -/// Indicates that the actor accepts the object. -/// -/// The target property can be used in certain circumstances to indicate the context into which the -/// object has been accepted. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Accept { - #[serde(rename = "type")] - kind: AcceptType, - - #[serde(flatten)] - pub accept_props: AcceptProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Accept {} -impl ObjectExt for Accept { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Accept { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Accept {} -impl ActivityExt for Accept { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor has added the object to the target. -/// -/// If the target property is not explicitly specified, the target would need to be determined -/// implicitly by context. The origin can be used to identify the context from which the object -/// originated. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Add { - #[serde(rename = "type")] - kind: AddType, - - #[serde(flatten)] - pub add_props: AddProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Add {} -impl ObjectExt for Add { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Add { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Add {} -impl ActivityExt for Add { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor has moved object from origin to target. -/// -/// If the origin or target are not specified, either can be determined by context. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct AMove { - #[serde(rename = "type")] - kind: MoveType, - - #[serde(flatten)] - pub move_props: MoveProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for AMove {} -impl ObjectExt for AMove { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for AMove { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for AMove {} -impl ActivityExt for AMove { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor is calling the target's attention the object. -/// -/// The origin typically has no defined meaning. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Announce { - #[serde(rename = "type")] - kind: AnnounceType, - - #[serde(flatten)] - pub announce_props: AnnounceProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Announce {} -impl ObjectExt for Announce { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Announce { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Announce {} -impl ActivityExt for Announce { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// An IntransitiveActivity that indicates that the actor has arrived at the location. -/// -/// The origin can be used to identify the context from which the actor originated. The target -/// typically has no defined meaning. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Arrive { - #[serde(rename = "type")] - kind: ArriveType, - - #[serde(flatten)] - pub arrive_props: ArriveProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Arrive {} -impl ObjectExt for Arrive { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Arrive { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Arrive {} -impl ActivityExt for Arrive { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} -impl IntransitiveActivity for Arrive {} - -/// Indicates that the actor is blocking the object. -/// -/// Blocking is a stronger form of Ignore. The typical use is to support social systems that allow -/// one user to block activities or content of other users. The target and origin typically have no -/// defined meaning. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Block { - #[serde(rename = "type")] - kind: BlockType, - - #[serde(flatten)] - pub block_props: BlockProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Block {} -impl ObjectExt for Block { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Block { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Block {} -impl ActivityExt for Block { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor has created the object. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Create { - #[serde(rename = "type")] - kind: CreateType, - - #[serde(flatten)] - pub create_props: CreateProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Create {} -impl ObjectExt for Create { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Create { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Create {} -impl ActivityExt for Create { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor has deleted the object. -/// -/// If specified, the origin indicates the context from which the object was deleted. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Delete { - #[serde(rename = "type")] - kind: DeleteType, - - #[serde(flatten)] - pub delete_props: DeleteProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Delete {} -impl ObjectExt for Delete { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Delete { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Delete {} -impl ActivityExt for Delete { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor dislikes the object. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Dislike { - #[serde(rename = "type")] - kind: DislikeType, - - #[serde(flatten)] - pub dislike_props: DislikeProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Dislike {} -impl ObjectExt for Dislike { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Dislike { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Dislike {} -impl ActivityExt for Dislike { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor is "flagging" the object. -/// -/// Flagging is defined in the sense common to many social platforms as reporting content as being -/// inappropriate for any number of reasons. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Flag { - #[serde(rename = "type")] - kind: FlagType, - - #[serde(flatten)] - pub flag_props: FlagProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Flag {} -impl ObjectExt for Flag { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Flag { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Flag {} -impl ActivityExt for Flag { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor is "following" the object. -/// -/// Following is defined in the sense typically used within Social systems in which the actor is -/// interested in any activity performed by or on the object. The target and origin typically have -/// no defined meaning. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Follow { - #[serde(rename = "type")] - kind: FollowType, - - #[serde(flatten)] - pub follow_props: FollowProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Follow {} -impl ObjectExt for Follow { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Follow { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Follow {} -impl ActivityExt for Follow { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor is ignoring the object. -/// -/// The target and origin typically have no defined meaning. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Ignore { - #[serde(rename = "type")] - kind: IgnoreType, - - #[serde(flatten)] - pub ignore_props: IgnoreProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Ignore {} -impl ObjectExt for Ignore { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Ignore { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Ignore {} -impl ActivityExt for Ignore { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// A specialization of Offer in which the actor is extending an invitation for the object to the -/// target. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Invite { - #[serde(rename = "type")] - kind: InviteType, - - #[serde(flatten)] - pub invite_props: InviteProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Invite {} -impl ObjectExt for Invite { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Invite { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Invite {} -impl ActivityExt for Invite { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor has joined the object. -/// -/// The target and origin typically have no defined meaning -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Join { - #[serde(rename = "type")] - kind: JoinType, - - #[serde(flatten)] - pub join_props: JoinProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Join {} -impl ObjectExt for Join { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Join { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Join {} -impl ActivityExt for Join { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor has left the object. -/// -/// The target and origin typically have no meaning. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Leave { - #[serde(rename = "type")] - kind: LeaveType, - - #[serde(flatten)] - pub leave_props: LeaveProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Leave {} -impl ObjectExt for Leave { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Leave { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Leave {} -impl ActivityExt for Leave { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor likes, recommends or endorses the object. -/// -/// The target and origin typically have no defined meaning. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Like { - #[serde(rename = "type")] - kind: LikeType, - - #[serde(flatten)] - pub like_props: LikeProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Like {} -impl ObjectExt for Like { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Like { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Like {} -impl ActivityExt for Like { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor has listened to the object. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Listen { - #[serde(rename = "type")] - kind: ListenType, - - #[serde(flatten)] - pub listen_props: ListenProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Listen {} -impl ObjectExt for Listen { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Listen { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Listen {} -impl ActivityExt for Listen { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Indicates that the actor is offering the object. -/// -/// If specified, the target indicates the entity to which the object is being offered. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Offer { - #[serde(rename = "type")] - kind: OfferType, - - #[serde(flatten)] - pub offer_props: OfferProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -impl Object for Offer {} -impl ObjectExt for Offer { - fn props(&self) -> &ObjectProperties { - &self.object_props - } - - fn props_mut(&mut self) -> &mut ObjectProperties { - &mut self.object_props - } -} -impl ApObjectExt for Offer { - fn props(&self) -> &ApObjectProperties { - &self.ap_object_props - } - - fn props_mut(&mut self) -> &mut ApObjectProperties { - &mut self.ap_object_props - } -} -impl Activity for Offer {} -impl ActivityExt for Offer { - fn props(&self) -> &ActivityProperties { - &self.activity_props - } - - fn props_mut(&mut self) -> &mut ActivityProperties { - &mut self.activity_props - } -} - -/// Represents a question being asked. -/// -/// Question objects are an extension of IntransitiveActivity. That is, the Question object is an -/// Activity, but the direct object is the question itself and therefore it would not contain an -/// object property. -/// -/// Either of the anyOf and oneOf properties MAY be used to express possible answers, but a -/// Question object MUST NOT have both properties. -#[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct Question { - #[serde(rename = "type")] - kind: QuestionType, - - #[serde(flatten)] - pub question_props: QuestionProperties, - - #[serde(flatten)] - pub object_props: ObjectProperties, - - #[serde(flatten)] - pub ap_object_props: ApObjectProperties, - - #[serde(flatten)] - pub activity_props: ActivityProperties, -} - -imp |