Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions dongle-smartcontract/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ pub fn publish_review_event(
project_id: u64,
reviewer: Address,
action: ReviewAction,
ipfs_cid: Option<String>,
comment_cid: Option<String>,
content_cid: Option<String>,
owner_response: Option<String>,
created_at: u64,
updated_at: u64,
Expand All @@ -185,10 +184,9 @@ pub fn publish_review_event(
reviewer: reviewer.clone(),
action: action.clone(),
timestamp: env.ledger().timestamp(),
ipfs_cid,
content_cid,
created_at,
updated_at,
comment_cid,
owner_response,
};

Expand Down
20 changes: 4 additions & 16 deletions dongle-smartcontract/src/review_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ impl ReviewRegistry {
project_id,
reviewer: reviewer.clone(),
rating,
ipfs_cid: comment_cid.clone(),
comment_cid: comment_cid.clone(),
content_cid: comment_cid.clone(),
owner_response: None,
created_at: now,
updated_at: now,
Expand Down Expand Up @@ -128,7 +127,6 @@ impl ReviewRegistry {
reviewer,
ReviewAction::Submitted,
comment_cid.clone(),
comment_cid,
None,
now,
now,
Expand Down Expand Up @@ -185,8 +183,7 @@ impl ReviewRegistry {
let old_rating = review.rating;
let now = env.ledger().timestamp();
review.rating = rating;
review.ipfs_cid = comment_cid.clone();
review.comment_cid = comment_cid.clone();
review.content_cid = comment_cid.clone();
review.updated_at = now;

// Get current stats
Expand Down Expand Up @@ -225,7 +222,6 @@ impl ReviewRegistry {
reviewer,
ReviewAction::Updated,
comment_cid.clone(),
comment_cid,
review.owner_response.clone(),
review.created_at,
now,
Expand Down Expand Up @@ -332,7 +328,6 @@ impl ReviewRegistry {
reviewer,
ReviewAction::Deleted,
None,
None,
existing.owner_response.clone(),
existing.created_at,
now,
Expand Down Expand Up @@ -392,8 +387,7 @@ impl ReviewRegistry {
project_id,
reviewer,
ReviewAction::Updated,
review.ipfs_cid.clone(),
review.comment_cid.clone(),
review.content_cid.clone(),
review.owner_response.clone(),
review.created_at,
now,
Expand All @@ -412,13 +406,7 @@ impl ReviewRegistry {
}

pub fn get_review_cid(env: &Env, project_id: u64, reviewer: Address) -> Option<String> {
Self::get_review(env, project_id, reviewer).and_then(|review| {
if let Some(cid) = review.ipfs_cid {
Some(cid)
} else {
review.comment_cid
}
})
Self::get_review(env, project_id, reviewer).and_then(|review| review.content_cid)
}

pub fn get_project_review_cids(env: &Env, project_id: u64) -> Vec<(Address, String)> {
Expand Down
Loading
Loading