1 use crate::{fetcher::post_or_comment::PostOrComment, objects::person::ApubPerson};
2 use activitystreams::unparsed::Unparsed;
4 use lemmy_apub_lib::object_id::ObjectId;
5 use lemmy_utils::LemmyError;
6 use serde::{Deserialize, Serialize};
7 use std::convert::TryFrom;
8 use strum_macros::ToString;
11 #[derive(Clone, Debug, Deserialize, Serialize)]
12 #[serde(rename_all = "camelCase")]
14 pub(crate) actor: ObjectId<ApubPerson>,
15 pub(crate) to: Vec<Url>,
16 pub(crate) object: ObjectId<PostOrComment>,
17 pub(crate) cc: Vec<Url>,
18 #[serde(rename = "type")]
19 pub(crate) kind: VoteType,
22 pub(crate) unparsed: Unparsed,
25 #[derive(Clone, Debug, ToString, Deserialize, Serialize)]
31 impl TryFrom<i16> for VoteType {
32 type Error = LemmyError;
34 fn try_from(value: i16) -> Result<Self, Self::Error> {
36 1 => Ok(VoteType::Like),
37 -1 => Ok(VoteType::Dislike),
38 _ => Err(anyhow!("invalid vote value").into()),
43 impl From<&VoteType> for i16 {
44 fn from(value: &VoteType) -> i16 {
47 VoteType::Dislike => -1,