Skip to content

Commit

Permalink
Wrap Post in PostEvent with Arc
Browse files Browse the repository at this point in the history
  • Loading branch information
KitaitiMakoto committed Jan 16, 2021
1 parent 6c1dd66 commit 6dd7300
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions plume-models/src/posts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use plume_common::{
};
use riker::actors::{Publish, Tell};
use std::collections::HashSet;
use std::sync::Arc;

pub type LicensedArticle = CustomObject<Licensed, Article>;

Expand Down Expand Up @@ -556,7 +557,7 @@ impl Post {
fn publish_published(&self) {
POST_CHAN.tell(
Publish {
msg: PostPublished(self.clone()),
msg: PostPublished(Arc::new(self.clone())),
topic: "post.published".into(),
},
None,
Expand All @@ -566,7 +567,7 @@ impl Post {
fn publish_updated(&self) {
POST_CHAN.tell(
Publish {
msg: PostUpdated(self.clone()),
msg: PostUpdated(Arc::new(self.clone())),
topic: "post.updated".into(),
},
None,
Expand All @@ -576,7 +577,7 @@ impl Post {
fn publish_deleted(&self) {
POST_CHAN.tell(
Publish {
msg: PostDeleted(self.clone()),
msg: PostDeleted(Arc::new(self.clone())),
topic: "post.deleted".into(),
},
None,
Expand Down Expand Up @@ -836,12 +837,12 @@ impl IntoId for Post {

#[derive(Clone, Debug)]
pub enum PostEvent {
PostPublished(Post),
PostUpdated(Post),
PostDeleted(Post),
PostPublished(Arc<Post>),
PostUpdated(Arc<Post>),
PostDeleted(Arc<Post>),
}

impl From<PostEvent> for Post {
impl From<PostEvent> for Arc<Post> {
fn from(event: PostEvent) -> Self {
use PostEvent::*;

Expand Down

0 comments on commit 6dd7300

Please sign in to comment.