radicle-feed 0.1.1

A Radicle feed library for implementing Radicle COB feeds
Documentation
use serde::{Deserialize, Serialize};

use radicle::cob::{ObjectId, TypeName};
use radicle::node::{Alias, AliasStore};
use radicle::prelude::RepoId;
use radicle::{cob::Timestamp, git::Oid};

#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ActionEntry {
    pub operation_id: Oid,
    pub cob_id: ObjectId,
    pub rid: RepoId,
    pub timestamp: Timestamp,
    pub action: String,
    pub author: Author,
    pub typename: TypeName,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Author {
    pub did: radicle::identity::Did,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub alias: Option<Alias>,
}

impl Author {
    pub fn new(did: &radicle::identity::Did, aliases: &impl AliasStore) -> Self {
        Self {
            did: *did,
            alias: aliases.alias(did),
        }
    }
}