aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream/streamitem.rs
blob: 343ed28a827399643e031483274417a5d3b9886a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
 * Representation of a stream item, as received from the zot api streams.
 *
 * SPDX-FileCopyrightText: 2023 Eilertsens Kodeknekkeri
 * SPDX-FileCopyrightText: 2023 Harald Eilertsen <haraldei@anduin.net>
 *
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

use super::verb::Verb;

use serde::Deserialize;

#[derive(Debug, Deserialize, PartialEq)]
pub enum StreamItemType {
    #[serde(rename="activity")]
    Activity,
}

#[derive(Debug, Deserialize, PartialEq)]
pub enum StreamItemEncoding {
    #[serde(rename="zot")]
    Zot,
}

/**
 * Represents an item as returned by the stream API's.
 */
#[derive(Debug, Deserialize, PartialEq)]
pub struct StreamItem {
    #[serde(rename="type")]
    pub item_type: StreamItemType,
    pub encoding: StreamItemEncoding,

    pub verb: Verb,

    pub title: String,
    pub summary: String,
    pub body: String,
}

impl StreamItem {
    pub fn is_post(&self) -> bool {
        self.verb == Verb::Post
    }
}