2 fetcher::{object_id::ObjectId, post_or_comment::PostOrComment},
3 objects::person::ApubPerson,
5 use activitystreams::unparsed::Unparsed;
7 use lemmy_apub_lib::traits::ActivityFields;
8 use lemmy_utils::LemmyError;
9 use serde::{Deserialize, Serialize};
10 use std::convert::TryFrom;
11 use strum_macros::ToString;
14 #[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
15 #[serde(rename_all = "camelCase")]
17 pub(crate) actor: ObjectId<ApubPerson>,
18 pub(crate) to: Vec<Url>,
19 pub(crate) object: ObjectId<PostOrComment>,
20 pub(crate) cc: Vec<Url>,
21 #[serde(rename = "type")]
22 pub(crate) kind: VoteType,
25 pub(crate) unparsed: Unparsed,
28 #[derive(Clone, Debug, ToString, Deserialize, Serialize)]
34 impl TryFrom<i16> for VoteType {
35 type Error = LemmyError;
37 fn try_from(value: i16) -> Result<Self, Self::Error> {
39 1 => Ok(VoteType::Like),
40 -1 => Ok(VoteType::Dislike),
41 _ => Err(anyhow!("invalid vote value").into()),
46 impl From<&VoteType> for i16 {
47 fn from(value: &VoteType) -> i16 {
50 VoteType::Dislike => -1,