-#[derive(Clone, Debug, ToString, Deserialize, Serialize)]
-pub enum VoteType {
- Like,
- Dislike,
-}
-
-impl TryFrom<i16> for VoteType {
- type Error = LemmyError;
-
- fn try_from(value: i16) -> Result<Self, Self::Error> {
- match value {
- 1 => Ok(VoteType::Like),
- -1 => Ok(VoteType::Dislike),
- _ => Err(anyhow!("invalid vote value").into()),
- }
- }
-}
-
-impl From<&VoteType> for i16 {
- fn from(value: &VoteType) -> i16 {
- match value {
- VoteType::Like => 1,
- VoteType::Dislike => -1,
- }
- }
-}
-
-#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
-#[serde(rename_all = "camelCase")]
-pub struct Vote {
- actor: ObjectId<ApubPerson>,
- to: PublicUrlMigration,
- pub(in crate::activities::voting) object: ObjectId<PostOrComment>,
- cc: [ObjectId<ApubCommunity>; 1],
- #[serde(rename = "type")]
- pub(in crate::activities::voting) kind: VoteType,
- id: Url,
- #[serde(rename = "@context")]
- context: OneOrMany<AnyBase>,
- #[serde(flatten)]
- unparsed: Unparsed,
-}
-