1 use crate::{fetcher::post_or_comment::PostOrComment, objects::person::ApubPerson};
2 use activitypub_federation::core::object_id::ObjectId;
3 use lemmy_utils::error::LemmyError;
4 use serde::{Deserialize, Serialize};
5 use std::convert::TryFrom;
6 use strum_macros::Display;
9 #[derive(Clone, Debug, Deserialize, Serialize)]
10 #[serde(rename_all = "camelCase")]
12 pub(crate) actor: ObjectId<ApubPerson>,
13 pub(crate) object: ObjectId<PostOrComment>,
14 #[serde(rename = "type")]
15 pub(crate) kind: VoteType,
19 #[derive(Clone, Debug, Display, Deserialize, Serialize, PartialEq, Eq)]
25 impl TryFrom<i16> for VoteType {
26 type Error = LemmyError;
28 fn try_from(value: i16) -> Result<Self, Self::Error> {
30 1 => Ok(VoteType::Like),
31 -1 => Ok(VoteType::Dislike),
32 _ => Err(LemmyError::from_message("invalid vote value")),
37 impl From<&VoteType> for i16 {
38 fn from(value: &VoteType) -> i16 {
41 VoteType::Dislike => -1,