2 fetcher::post_or_comment::PostOrComment,
3 objects::person::ApubPerson,
7 use lemmy_apub_lib::object_id::ObjectId;
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)]
15 #[serde(rename_all = "camelCase")]
17 pub(crate) actor: ObjectId<ApubPerson>,
18 #[serde(deserialize_with = "crate::deserialize_one_or_many")]
19 pub(crate) to: Vec<Url>,
20 pub(crate) object: ObjectId<PostOrComment>,
21 #[serde(deserialize_with = "crate::deserialize_one_or_many")]
22 pub(crate) cc: Vec<Url>,
23 #[serde(rename = "type")]
24 pub(crate) kind: VoteType,
27 pub(crate) unparsed: Unparsed,
30 #[derive(Clone, Debug, ToString, Deserialize, Serialize)]
36 impl TryFrom<i16> for VoteType {
37 type Error = LemmyError;
39 fn try_from(value: i16) -> Result<Self, Self::Error> {
41 1 => Ok(VoteType::Like),
42 -1 => Ok(VoteType::Dislike),
43 _ => Err(anyhow!("invalid vote value").into()),
48 impl From<&VoteType> for i16 {
49 fn from(value: &VoteType) -> i16 {
52 VoteType::Dislike => -1,