mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 19:30:38 +08:00
Take a &identity::Did for the Author constructor
This commit is contained in:
@@ -22,10 +22,10 @@ pub struct Author {
|
||||
}
|
||||
|
||||
impl Author {
|
||||
pub fn new(did: identity::Did, aliases: &impl AliasStore) -> Self {
|
||||
pub fn new(did: &identity::Did, aliases: &impl AliasStore) -> Self {
|
||||
Self {
|
||||
did,
|
||||
alias: aliases.alias(&did),
|
||||
did: *did,
|
||||
alias: aliases.alias(did),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ impl Issue {
|
||||
|
||||
Self {
|
||||
id: id.to_string(),
|
||||
author: cobs::Author::new(*issue.author().id(), aliases),
|
||||
author: cobs::Author::new(issue.author().id(), aliases),
|
||||
title: issue.title().to_string(),
|
||||
state: (*issue.state()).into(),
|
||||
assignees: issue
|
||||
.assignees()
|
||||
.map(|did| cobs::Author::new(*did, aliases))
|
||||
.map(|did| cobs::Author::new(did, aliases))
|
||||
.collect::<Vec<_>>(),
|
||||
body: cobs::thread::Comment::<cobs::Never>::new(
|
||||
*root_oid,
|
||||
|
||||
@@ -37,14 +37,14 @@ impl Patch {
|
||||
pub fn new(id: patch::PatchId, patch: &patch::Patch, aliases: &impl AliasStore) -> Self {
|
||||
Self {
|
||||
id: id.to_string(),
|
||||
author: cobs::Author::new(*patch.author().id(), aliases),
|
||||
author: cobs::Author::new(patch.author().id(), aliases),
|
||||
title: patch.title().to_string(),
|
||||
state: patch.state().clone().into(),
|
||||
base: *patch.base(),
|
||||
head: *patch.head(),
|
||||
assignees: patch
|
||||
.assignees()
|
||||
.map(|did| cobs::Author::new(did, aliases))
|
||||
.map(|did| cobs::Author::new(&did, aliases))
|
||||
.collect::<Vec<_>>(),
|
||||
labels: patch.labels().cloned().collect::<Vec<_>>(),
|
||||
timestamp: patch.timestamp(),
|
||||
@@ -142,7 +142,7 @@ impl Revision {
|
||||
pub fn new(value: cob::patch::Revision, aliases: &impl AliasStore) -> Self {
|
||||
Self {
|
||||
id: value.id(),
|
||||
author: cobs::Author::new(*value.author().id(), aliases),
|
||||
author: cobs::Author::new(value.author().id(), aliases),
|
||||
description: value
|
||||
.edits()
|
||||
.map(|e| Edit::new(e, aliases))
|
||||
@@ -181,7 +181,7 @@ impl Revision {
|
||||
.map(|(emoji, authors)| {
|
||||
cobs::thread::Reaction::new(
|
||||
*emoji,
|
||||
authors,
|
||||
authors.into_iter().map(|a| a.into()).collect::<Vec<_>>(),
|
||||
location
|
||||
.as_ref()
|
||||
.map(|l| cobs::thread::CodeLocation::new(l.clone())),
|
||||
@@ -211,7 +211,7 @@ pub struct Edit {
|
||||
impl Edit {
|
||||
pub fn new(edit: &cob::thread::Edit, aliases: &impl AliasStore) -> Self {
|
||||
Self {
|
||||
author: cobs::Author::new(edit.author.into(), aliases),
|
||||
author: cobs::Author::new(&edit.author.into(), aliases),
|
||||
timestamp: edit.timestamp,
|
||||
body: edit.body.clone(),
|
||||
embeds: edit
|
||||
@@ -251,7 +251,7 @@ impl Review {
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
author: cobs::Author::new(review.author().id, aliases),
|
||||
author: cobs::Author::new(&review.author().id, aliases),
|
||||
verdict: review.verdict(),
|
||||
summary: review.summary().map(|s| s.to_string()),
|
||||
comments: review
|
||||
|
||||
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
use radicle::node::AliasStore;
|
||||
use radicle::{cob, crypto, git};
|
||||
use radicle::{cob, git, identity};
|
||||
|
||||
use crate::cobs;
|
||||
|
||||
@@ -59,7 +59,7 @@ impl Comment<CodeLocation> {
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
author: cobs::Author::new(comment.author().into(), aliases),
|
||||
author: cobs::Author::new(&comment.author().into(), aliases),
|
||||
edits: comment
|
||||
.edits()
|
||||
.map(|e| cobs::patch::Edit::new(e, aliases))
|
||||
@@ -68,7 +68,12 @@ impl Comment<CodeLocation> {
|
||||
.reactions()
|
||||
.into_iter()
|
||||
.map(|(reaction, authors)| {
|
||||
cobs::thread::Reaction::new(*reaction, authors, None, aliases)
|
||||
cobs::thread::Reaction::new(
|
||||
*reaction,
|
||||
authors.into_iter().map(|s| s.into()).collect(),
|
||||
None,
|
||||
aliases,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
reply_to: comment.reply_to(),
|
||||
@@ -92,7 +97,7 @@ impl Comment<cobs::Never> {
|
||||
) -> Self {
|
||||
Self {
|
||||
id,
|
||||
author: cobs::Author::new(comment.author().into(), aliases),
|
||||
author: cobs::Author::new(&comment.author().into(), aliases),
|
||||
edits: comment
|
||||
.edits()
|
||||
.map(|e| cobs::patch::Edit::new(e, aliases))
|
||||
@@ -101,7 +106,12 @@ impl Comment<cobs::Never> {
|
||||
.reactions()
|
||||
.into_iter()
|
||||
.map(|(reaction, authors)| {
|
||||
cobs::thread::Reaction::new(*reaction, authors, None, aliases)
|
||||
cobs::thread::Reaction::new(
|
||||
*reaction,
|
||||
authors.into_iter().map(|m| m.into()).collect::<Vec<_>>(),
|
||||
None,
|
||||
aliases,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
reply_to: comment.reply_to(),
|
||||
@@ -132,7 +142,7 @@ pub struct Reaction {
|
||||
impl Reaction {
|
||||
pub fn new(
|
||||
emoji: cob::Reaction,
|
||||
authors: Vec<&crypto::PublicKey>,
|
||||
authors: Vec<identity::Did>,
|
||||
location: Option<CodeLocation>,
|
||||
aliases: &impl AliasStore,
|
||||
) -> Self {
|
||||
@@ -140,7 +150,7 @@ impl Reaction {
|
||||
emoji,
|
||||
authors: authors
|
||||
.into_iter()
|
||||
.map(|a| cobs::Author::new(a.into(), aliases))
|
||||
.map(|did| cobs::Author::new(&did, aliases))
|
||||
.collect::<Vec<_>>(),
|
||||
location,
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub trait Cobs: Profile {
|
||||
Some(crate::cobs::issue::Operation {
|
||||
entry_id: op.id,
|
||||
action,
|
||||
author: crate::cobs::Author::new(op.author.into(), &aliases),
|
||||
author: crate::cobs::Author::new(&op.author.into(), &aliases),
|
||||
timestamp: op.timestamp,
|
||||
})
|
||||
},
|
||||
|
||||
@@ -92,9 +92,8 @@ pub trait Repo: Profile {
|
||||
let profile = self.profile();
|
||||
let aliases = profile.aliases();
|
||||
let delegates = doc
|
||||
.delegates
|
||||
.clone()
|
||||
.into_iter()
|
||||
.delegates()
|
||||
.iter()
|
||||
.map(|did| cobs::Author::new(did, &aliases))
|
||||
.collect::<Vec<_>>();
|
||||
let db = profile.database()?;
|
||||
|
||||
Reference in New Issue
Block a user