fediverse/types/core/
activity.rs

1use crate::types::core::object::ObjectProperties;
2use crate::types::properties::actor::Actor;
3use crate::types::properties::instrument::Instrument;
4use crate::types::properties::object::Object;
5use crate::types::properties::origin::Origin;
6use crate::types::properties::result::Result;
7use crate::types::properties::target::Target;
8
9/// An `Activity` is a subtype of [Object](crate::types::core::object::Object) that describes some form of
10/// action that may happen, is currently happening, or has already happened. The `Activity` type
11/// itself serves as an abstract base type for all types of activities.
12///
13/// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-activity>
14#[derive(Default, Debug, PartialEq)]
15pub struct Activity {
16    r#type: String,
17    pub object_properties: ObjectProperties,
18    pub activity_properties: ActivityProperties,
19}
20
21impl Activity {
22    pub fn new(
23        object_properties: ObjectProperties,
24        activity_properties: ActivityProperties,
25    ) -> Self {
26        Self {
27            r#type: "Activity".to_string(),
28            object_properties,
29            activity_properties,
30        }
31    }
32}
33
34#[derive(Default, Debug, PartialEq)]
35pub struct ActivityProperties {
36    pub actor: Option<Actor>,
37    pub object: Option<Object>,
38    pub target: Option<Target>,
39    pub result: Option<Result>,
40    pub origin: Option<Origin>,
41    pub instrument: Option<Instrument>,
42}
43
44// TODO: export again as standalone types
45/// The Activity type itself serves as an abstract base type for all types of activities.
46#[derive(Debug, PartialEq, Eq)]
47pub enum ActivityType {
48    /// It is important to note that the `Activity` type itself does not carry any specific
49    /// semantics about the kind of action being taken.
50    Activity,
51
52    /// Indicates that the `actor` accepts the `object`.
53    ///
54    /// The `target` property can be used in certain circumstances to indicate the context into which
55    /// the `object` has been accepted.
56    ///
57    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accept>
58    Accept,
59
60    /// Indicates that the `actor` has added the `object` to the `target`.
61    ///
62    /// If the `target` property is not explicitly specified, the target would need to be determined
63    /// implicitly by context. The `origin` can be used to identify the context from which the `object`
64    /// originated.
65    ///
66    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-add>
67    Add,
68
69    /// Indicates that the `actor` is calling the `target`'s attention the `object`.
70    ///
71    /// The `origin` typically has no defined meaning.
72    ///
73    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce>
74    Announce,
75
76    /// Indicates that the `actor` is blocking the `object`. Blocking is a stronger form of [Ignore](crate::types::core::activity::ActivityType::Ignore).
77    ///
78    /// The typical use is to support social systems that allow one user to block activities or content
79    /// of other users. The `target` and `origin` typically have no defined meaning.
80    ///
81    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-block>
82    Block,
83
84    /// Indicates that the `actor` has created the `object`.
85    ///
86    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create>
87    Create,
88
89    /// Indicates that the `actor` has deleted the `object`.
90    ///
91    /// If specified, the `origin` indicates the context from which the `object` was deleted.
92    ///
93    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-delete>
94    Delete,
95
96    /// Indicates that the `actor` dislikes the `object`.
97    ///
98    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-dislike>
99    Dislike,
100
101    /// Indicates that the `actor` is "flagging" the `object`.
102    ///
103    /// Flagging is defined in the sense common to many social platforms as reporting content as being
104    /// inappropriate for any number of reasons.
105    ///
106    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-flag>
107    Flag,
108
109    /// Indicates that the `actor` is "following" the `object`.
110    ///
111    /// Following is defined in the sense typically used within Social systems in which the actor is
112    /// interested in any activity performed by or on the object. The `target` and `origin` typically
113    /// have no defined meaning.
114    ///
115    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow>
116    Follow,
117
118    /// Indicates that the `actor` is ignoring the `object`.
119    ///
120    /// The `target` and `origin` typically have no defined meaning.
121    ///
122    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-ignore>
123    Ignore,
124
125    /// A specialization of [Offer](crate::types::core::activity::ActivityType::Offer) in which the `actor`
126    /// is extending an invitation for the `object` to the `target`.
127    ///
128    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-invite>
129    Invite,
130
131    /// Indicates that the `actor` has joined the `object`.
132    ///
133    /// The `target` and `origin` typically have no defined meaning.
134    ///
135    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-join>
136    Join,
137
138    /// Indicates that the `actor` has left the `object`.
139    ///
140    /// The `target` and `origin` typically have no defined meaning.
141    ///
142    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-leave>
143    Leave,
144
145    /// Indicates that the `actor` likes, recommends or endorses the `object`.
146    ///
147    /// The `target` and `origin` typically have no defined meaning.
148    ///
149    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-like>
150    Like,
151
152    /// Indicates that the `actor` has listened to the `object`.
153    ///
154    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-listen>
155    Listen,
156
157    /// Indicates that the `actor` has moved `object` from `origin` to `target`.
158    ///
159    /// If the `origin` or `target` are not specified, either can be determined by context.
160    ///
161    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-move>
162    Move,
163
164    /// Indicates that the `actor` is offering the `object`.
165    ///
166    /// If specified, the `target` indicates the entity to which the `object` is being offered.
167    ///
168    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-offer>
169    Offer,
170
171    /// Indicates that the `actor` has updated the `object`.
172    ///
173    /// Note, however, that this vocabulary does not define a mechanism for describing the actual set
174    /// of modifications made to `object`.
175    ///
176    /// The `target` and `origin` typically have no defined meaning.
177    ///
178    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-read>
179    Read,
180
181    /// Indicates that the `actor` is rejecting the `object`.
182    ///
183    /// The `target` and `origin` typically have no defined meaning.
184    ///
185    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-reject>
186    Reject,
187
188    /// Indicates that the `actor` is removing the `object`.
189    ///
190    /// If specified, the `origin` indicates the context from which the `object` is being removed.
191    ///
192    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-remove>
193    Remove,
194
195    /// A specialization of [Accept](crate::types::core::activity::ActivityType::Accept) in which the
196    /// acceptance is tentative.
197    ///
198    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tentativeaccept>
199    TentativeAccept,
200
201    /// A specialization of [Reject](crate::types::core::activity::ActivityType::Reject) in which the
202    /// rejection is considered tentative.
203    ///
204    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tentativereject>
205    TentativeReject,
206
207    /// Indicates that the `actor` is undoing the `object`.
208    ///
209    /// In most cases, the `object` will be an [Activity](crate::types::core::activity::Activity)
210    /// describing some previously performed action (for instance, a person may have previously "liked"
211    /// an article but, for whatever reason, might choose to undo that like at some later point in time).
212    ///
213    /// The `target` and `origin` typically have no defined meaning.
214    ///
215    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-undo>
216    Undo,
217
218    /// Indicates that the `actor` has updated the `object`.
219    ///
220    /// Note, however, that this vocabulary does not define a mechanism for describing the actual set
221    /// of modifications made to `object`.
222    ///
223    /// The `target` and `origin` typically have no defined meaning.
224    ///
225    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update>
226    Update,
227
228    /// Indicates that the `actor` has viewed the `object`.
229    ///
230    /// Specifications: <https://www.w3.org/TR/activitystreams-vocabulary/#dfn-view>
231    View,
232}