mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-30 16:50:47 +08:00
httpd: Add comment edits to serialized json
This allows the display of any edits done to comments, replies and issue descriptions. This commit doesn't remove the body property which is the latest comment body but adds a edits property. Also adds an author property to the `Edit` struct, which allows us to see the author of an edit action.
This commit is contained in:
committed by
cloudhead
parent
e0bd20fa4b
commit
0d3bd3cf03
@@ -242,6 +242,7 @@ struct Comment<'a> {
|
||||
id: CommentId,
|
||||
author: Value,
|
||||
body: &'a str,
|
||||
edits: Vec<Value>,
|
||||
embeds: Vec<Embed<Uri>>,
|
||||
reactions: Vec<(&'a ActorId, &'a Reaction)>,
|
||||
#[serde(with = "radicle::serde_ext::localtime::time")]
|
||||
@@ -257,6 +258,17 @@ impl<'a> Comment<'a> {
|
||||
id: *id,
|
||||
author: author(&comment_author, aliases.alias(comment_author.id())),
|
||||
body: comment.body(),
|
||||
edits: comment
|
||||
.edits()
|
||||
.map(|edit| {
|
||||
json!({
|
||||
"author": author(&Author::from(edit.author), aliases.alias(&edit.author)),
|
||||
"body": edit.body,
|
||||
"timestamp": edit.timestamp,
|
||||
"embeds": edit.embeds,
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
embeds: comment.embeds().to_vec(),
|
||||
reactions: comment.reactions().collect::<Vec<_>>(),
|
||||
timestamp: comment.timestamp(),
|
||||
|
||||
@@ -1995,6 +1995,16 @@ mod routes {
|
||||
"id": DID
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"edits": [
|
||||
{
|
||||
"author": {
|
||||
"id": DID,
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [],
|
||||
},
|
||||
],
|
||||
"embeds": [],
|
||||
"reactions": [],
|
||||
"timestamp": TIMESTAMP,
|
||||
@@ -2070,6 +2080,21 @@ mod routes {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"edits": [
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [
|
||||
{
|
||||
"name": "example.html",
|
||||
"content": "git:b62df2ec90365e3749cd4fa431cb844492908b84",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"embeds": [
|
||||
{
|
||||
"name": "example.html",
|
||||
@@ -2203,6 +2228,29 @@ mod routes {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "EDIT: Change 'hello world' to 'hello anyone'",
|
||||
"edits": [
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [],
|
||||
},
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "EDIT: Change 'hello world' to 'hello anyone'",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
"content": "git:94381b429d7f7fe87e1bade52d893ab348ae29cc",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
@@ -2271,11 +2319,11 @@ mod routes {
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"assignees": [],
|
||||
"title": "Issue #1",
|
||||
"state": {
|
||||
"status": "open",
|
||||
},
|
||||
"assignees": [],
|
||||
"discussion": [
|
||||
{
|
||||
"id": ISSUE_DISCUSSION_ID,
|
||||
@@ -2283,6 +2331,16 @@ mod routes {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"edits": [
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "Change 'hello world' to 'hello everyone'",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [],
|
||||
},
|
||||
],
|
||||
"embeds": [],
|
||||
"reactions": [],
|
||||
"timestamp": TIMESTAMP,
|
||||
@@ -2295,6 +2353,21 @@ mod routes {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "This is a reply to the first comment",
|
||||
"edits": [
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "This is a reply to the first comment",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
"content": "git:94381b429d7f7fe87e1bade52d893ab348ae29cc",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
@@ -2931,6 +3004,34 @@ mod routes {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "EDIT: This is a root level comment",
|
||||
"edits": [
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "This is a root level comment",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
"content": "git:94381b429d7f7fe87e1bade52d893ab348ae29cc",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "EDIT: This is a root level comment",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
"content": "git:94381b429d7f7fe87e1bade52d893ab348ae29cc",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
@@ -2948,6 +3049,16 @@ mod routes {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "This is a root level comment",
|
||||
"edits": [
|
||||
{
|
||||
"author": {
|
||||
"id": CONTRIBUTOR_DID,
|
||||
},
|
||||
"body": "This is a root level comment",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"embeds": [],
|
||||
},
|
||||
],
|
||||
"embeds": [],
|
||||
"reactions": [],
|
||||
"timestamp": TIMESTAMP,
|
||||
@@ -3132,6 +3243,30 @@ mod routes {
|
||||
],
|
||||
"resolved": true,
|
||||
"body": "EDIT: This is a comment on a review",
|
||||
"edits": [
|
||||
{
|
||||
"author": "z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"body": "This is a comment on a review",
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
"content": "git:94381b429d7f7fe87e1bade52d893ab348ae29cc",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"author": "z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8",
|
||||
"timestamp": COMMENT_TIMESTAMP,
|
||||
"body": "EDIT: This is a comment on a review",
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
"content": "git:94381b429d7f7fe87e1bade52d893ab348ae29cc",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
"embeds": [
|
||||
{
|
||||
"name": "image.jpg",
|
||||
|
||||
@@ -37,6 +37,7 @@ pub const ISSUE_DISCUSSION_ID: &str = "d11b03464c9bf58b09460713c8e2c74f0725d3bd"
|
||||
pub const ISSUE_COMMENT_ID: &str = "e3aa754cb47d2299781fed49cc91c4b41e06c219";
|
||||
pub const SESSION_ID: &str = "u9MGAkkfkMOv0uDDB2WeUHBT7HbsO2Dy";
|
||||
pub const TIMESTAMP: u64 = 1671125284;
|
||||
pub const COMMENT_TIMESTAMP: u64 = 1671125284000;
|
||||
pub const CONTRIBUTOR_RID: &str = "rad:z4XaCmN3jLSeiMvW15YTDpNbDHFhG";
|
||||
pub const CONTRIBUTOR_DID: &str = "did:key:z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8";
|
||||
pub const CONTRIBUTOR_NID: &str = "z6Mkk7oqY4pPxhMmGEotDYsFo97vhCj85BLY1H256HrJmjN8";
|
||||
|
||||
Reference in New Issue
Block a user