(
&self,
comment_id: &str,
patch: PublishedCommentPatch,
)
| 581 | } |
| 582 | |
| 583 | pub async fn patch_published_comment( |
| 584 | &self, |
| 585 | comment_id: &str, |
| 586 | patch: PublishedCommentPatch, |
| 587 | ) -> Result<Option<PublishedCommentRecord>> { |
| 588 | let mut record = match self.get_published_comment_by_comment_id(comment_id).await? { |
| 589 | Some(record) => record, |
| 590 | None => return Ok(None), |
| 591 | }; |
| 592 | |
| 593 | if let Some(value) = patch.comment_text { |
| 594 | let trimmed = value.trim(); |
| 595 | if !trimmed.is_empty() { |
| 596 | record.comment_text = trimmed.to_string(); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | if let Some(value) = patch.ai_reply_markdown { |
| 601 | record.ai_reply_markdown = value.trim().to_string(); |
| 602 | } |
| 603 | |
| 604 | record.published_at = now_ms(); |
| 605 | let table = self.published_table().await?; |
| 606 | upsert_published_comment_record(&table, &record).await?; |
| 607 | Ok(Some(record)) |
| 608 | } |
| 609 | |
| 610 | pub async fn delete_published_comment(&self, comment_id: &str) -> Result<()> { |
| 611 | let table = self.published_table().await?; |
no test coverage detected