From 2bfc26faf29a7a0917ca8757c72ce0f885c6856d Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sat, 27 Mar 2021 23:54:09 +0900 Subject: [PATCH 1/6] [BUG FIX]Make RemoveFetchActor subscribe to channel once --- plume-models/src/remote_fetch_actor.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plume-models/src/remote_fetch_actor.rs b/plume-models/src/remote_fetch_actor.rs index da73b077..097fb1da 100644 --- a/plume-models/src/remote_fetch_actor.rs +++ b/plume-models/src/remote_fetch_actor.rs @@ -17,24 +17,22 @@ pub struct RemoteFetchActor { impl RemoteFetchActor { pub fn init(conn: DbPool) { - ACTOR_SYS + let actor = ACTOR_SYS .actor_of_args::("remote-fetch", conn) .expect("Failed to initialize remote fetch actor"); - } -} -impl Actor for RemoteFetchActor { - type Msg = UserEvent; - - fn pre_start(&mut self, ctx: &Context) { USER_CHAN.tell( Subscribe { - actor: Box::new(ctx.myself()), + actor: Box::new(actor), topic: "*".into(), }, None, ) } +} + +impl Actor for RemoteFetchActor { + type Msg = UserEvent; fn recv(&mut self, _ctx: &Context, msg: Self::Msg, _sender: Sender) { use UserEvent::*; From 77c08845b59504f78d82292b251d266b08752f64 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sat, 27 Mar 2021 23:55:26 +0900 Subject: [PATCH 2/6] [BUG FIX]Make SearchActor subscribe to channel once --- plume-models/src/search/actor.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plume-models/src/search/actor.rs b/plume-models/src/search/actor.rs index d71bc53f..d97718e0 100644 --- a/plume-models/src/search/actor.rs +++ b/plume-models/src/search/actor.rs @@ -13,24 +13,22 @@ pub struct SearchActor { impl SearchActor { pub fn init(searcher: Arc, conn: DbPool) { - ACTOR_SYS + let actor = ACTOR_SYS .actor_of_args::("search", (searcher, conn)) .expect("Failed to initialize searcher actor"); - } -} -impl Actor for SearchActor { - type Msg = PostEvent; - - fn pre_start(&mut self, ctx: &Context) { POST_CHAN.tell( Subscribe { - actor: Box::new(ctx.myself()), + actor: Box::new(actor), topic: "*".into(), }, None, ) } +} + +impl Actor for SearchActor { + type Msg = PostEvent; fn recv(&mut self, _ctx: &Context, msg: Self::Msg, _sender: Sender) { use PostEvent::*; From 74f99e25880d00971e18e63ccee51de536b6139c Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 28 Mar 2021 00:24:00 +0900 Subject: [PATCH 3/6] Upgrade Rust version --- rust-toolchain | 2 +- snap/snapcraft.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 85ff8d47..1aad10c1 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2021-01-15 +nightly-2021-03-25 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index d480fc0d..11bebfe0 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -25,7 +25,7 @@ parts: plume: plugin: rust source: . - rust-revision: nightly-2020-01-15 + rust-revision: nightly-2021-03-25 build-packages: - libssl-dev - pkg-config From 722165a734ec9a36940236ed559e9bc043e90a48 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 28 Mar 2021 01:37:44 +0900 Subject: [PATCH 4/6] Upgrade lexical-core crate --- Cargo.lock | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b052bc5..73673cf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "activitypub" version = "0.1.6" @@ -2037,13 +2039,13 @@ checksum = "f44db4199cdb049b494a92d105acbfa43c25b3925e33803923ba9580b7bc9e1a" [[package]] name = "lexical-core" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616" +checksum = "21f866863575d0e1d654fbeeabdc927292fdf862873dc3c96c6f753357e13374" dependencies = [ "arrayvec", "bitflags 1.2.1", - "cfg-if 0.1.10", + "cfg-if 1.0.0", "ryu", "static_assertions", ] From 9ed36b2aa39ff17b01fa39490c78d735c587c979 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 28 Mar 2021 03:12:20 +0900 Subject: [PATCH 5/6] Add changelog on actor subscription fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cea9de71..f2658a87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Percent-encode URI for remote_interact (#866, #857) - Menu animation not opening on iOS (#876, #897) +- Make actors subscribe to channel once (#913) ## [[0.6.0]] - 2020-12-29 From 8e50d95a7ab1299ebba0ad1a7b428704a364da1b Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 28 Mar 2021 03:46:37 +0900 Subject: [PATCH 6/6] Fix code according to clippy --- plume-models/src/comments.rs | 4 +--- plume-models/src/config.rs | 7 ++----- plume-models/src/lists.rs | 3 ++- plume-models/src/posts.rs | 8 +------- plume-models/src/safe_string.rs | 2 +- plume-models/src/timeline/query.rs | 5 ++--- plume-models/src/users.rs | 5 +---- src/routes/blogs.rs | 4 ++-- 8 files changed, 12 insertions(+), 26 deletions(-) diff --git a/plume-models/src/comments.rs b/plume-models/src/comments.rs index 377e2dda..2a9cac2f 100644 --- a/plume-models/src/comments.rs +++ b/plume-models/src/comments.rs @@ -255,9 +255,7 @@ impl FromId for Comment { .and_then(|m| { let author = &Post::get(conn, comm.post_id)?.get_authors(conn)?[0]; let not_author = m.link_props.href_string()? != author.ap_url.clone(); - Ok(Mention::from_activity( - conn, &m, comm.id, false, not_author, - )?) + Mention::from_activity(conn, &m, comm.id, false, not_author) }) .ok(); } diff --git a/plume-models/src/config.rs b/plume-models/src/config.rs index 3bd3623b..f69597f8 100644 --- a/plume-models/src/config.rs +++ b/plume-models/src/config.rs @@ -164,11 +164,8 @@ impl Default for LogoConfig { }; let mut custom_icons = env::vars() .filter_map(|(var, val)| { - if let Some(size) = var.strip_prefix("PLUME_LOGO_") { - Some((size.to_owned(), val)) - } else { - None - } + var.strip_prefix("PLUME_LOGO_") + .map(|size| (size.to_owned(), val)) }) .filter_map(|(var, val)| var.parse::().ok().map(|var| (var, val))) .map(|(dim, src)| Icon { diff --git a/plume-models/src/lists.rs b/plume-models/src/lists.rs index 895120d5..19d270b2 100644 --- a/plume-models/src/lists.rs +++ b/plume-models/src/lists.rs @@ -285,7 +285,8 @@ impl List { .select(list_elems::word) .load::>(conn) .map_err(Error::from) - .map(|r| r.into_iter().filter_map(|o| o).collect::>()) + // .map(|r| r.into_iter().filter_map(|o| o).collect::>()) + .map(|r| r.into_iter().flatten().collect::>()) } pub fn clear(&self, conn: &Connection) -> Result<()> { diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index dc0c2a56..f34d6cd0 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -443,13 +443,7 @@ impl Post { m, ) }) - .filter_map(|(id, m)| { - if let Some(id) = id { - Some((m, id)) - } else { - None - } - }) + .filter_map(|(id, m)| id.map(|id| (m, id))) .collect::>(); let old_mentions = Mention::list_for_post(&conn, self.id)?; diff --git a/plume-models/src/safe_string.rs b/plume-models/src/safe_string.rs index 086395f4..aafd02ae 100644 --- a/plume-models/src/safe_string.rs +++ b/plume-models/src/safe_string.rs @@ -156,7 +156,7 @@ impl<'de> Deserialize<'de> for SafeString { where D: Deserializer<'de>, { - Ok(deserializer.deserialize_string(SafeStringVisitor)?) + deserializer.deserialize_string(SafeStringVisitor) } } diff --git a/plume-models/src/timeline/query.rs b/plume-models/src/timeline/query.rs index 7c54dc4f..eef5255b 100644 --- a/plume-models/src/timeline/query.rs +++ b/plume-models/src/timeline/query.rs @@ -601,11 +601,10 @@ fn parse_l<'a, 'b>(stream: &'b [Token<'a>]) -> QueryResult<(&'b [Token<'a>], Lis } fn parse_m<'a, 'b>(mut stream: &'b [Token<'a>]) -> QueryResult<(&'b [Token<'a>], Vec<&'a str>)> { - let mut res: Vec<&str> = Vec::new(); - res.push(match stream.get(0)? { + let mut res: Vec<&str> = vec![match stream.get(0)? { Token::Word(_, _, w) => w, t => return t.get_error(Token::Word(0, 0, "any word")), - }); + }]; stream = &stream[1..]; while let Token::Comma(_) = stream[0] { res.push(match stream.get(1)? { diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 95b4d758..7924cfd4 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -486,10 +486,7 @@ impl User { .filter_map(|j| serde_json::from_value(j.clone()).ok()) .collect::>(); - let next = match json.get("next") { - Some(x) => Some(x.as_str().unwrap().to_owned()), - None => None, - }; + let next = json.get("next").map(|x| x.as_str().unwrap().to_owned()); Ok((items, next)) } pub fn fetch_outbox(&self) -> Result> { diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 294bf79a..df4da910 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -348,7 +348,7 @@ pub fn update( #[get("/~//outbox")] pub fn outbox(name: String, conn: DbConn) -> Option> { let blog = Blog::find_by_fqn(&conn, &name).ok()?; - Some(blog.outbox(&conn).ok()?) + blog.outbox(&conn).ok() } #[allow(unused_variables)] #[get("/~//outbox?")] @@ -358,7 +358,7 @@ pub fn outbox_page( conn: DbConn, ) -> Option> { let blog = Blog::find_by_fqn(&conn, &name).ok()?; - Some(blog.outbox_page(&conn, page.limits()).ok()?) + blog.outbox_page(&conn, page.limits()).ok() } #[get("/~//atom.xml")] pub fn atom_feed(name: String, conn: DbConn) -> Option> {