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