Merge pull request 'Make actors subscribe to channel once' (#913) from remote-fetch-once into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/913
This commit is contained in:
commit
fe92d95f6c
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
- Percent-encode URI for remote_interact (#866, #857)
|
- Percent-encode URI for remote_interact (#866, #857)
|
||||||
- Menu animation not opening on iOS (#876, #897)
|
- Menu animation not opening on iOS (#876, #897)
|
||||||
|
- Make actors subscribe to channel once (#913)
|
||||||
|
|
||||||
## [[0.6.0]] - 2020-12-29
|
## [[0.6.0]] - 2020-12-29
|
||||||
|
|
||||||
|
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -1,5 +1,7 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "activitypub"
|
name = "activitypub"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
@ -2037,13 +2039,13 @@ checksum = "f44db4199cdb049b494a92d105acbfa43c25b3925e33803923ba9580b7bc9e1a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lexical-core"
|
name = "lexical-core"
|
||||||
version = "0.7.4"
|
version = "0.7.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "db65c6da02e61f55dae90a0ae427b2a5f6b3e8db09f58d10efab23af92592616"
|
checksum = "21f866863575d0e1d654fbeeabdc927292fdf862873dc3c96c6f753357e13374"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"bitflags 1.2.1",
|
"bitflags 1.2.1",
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 1.0.0",
|
||||||
"ryu",
|
"ryu",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
]
|
]
|
||||||
|
@ -255,9 +255,7 @@ impl FromId<DbConn> for Comment {
|
|||||||
.and_then(|m| {
|
.and_then(|m| {
|
||||||
let author = &Post::get(conn, comm.post_id)?.get_authors(conn)?[0];
|
let author = &Post::get(conn, comm.post_id)?.get_authors(conn)?[0];
|
||||||
let not_author = m.link_props.href_string()? != author.ap_url.clone();
|
let not_author = m.link_props.href_string()? != author.ap_url.clone();
|
||||||
Ok(Mention::from_activity(
|
Mention::from_activity(conn, &m, comm.id, false, not_author)
|
||||||
conn, &m, comm.id, false, not_author,
|
|
||||||
)?)
|
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
@ -164,11 +164,8 @@ impl Default for LogoConfig {
|
|||||||
};
|
};
|
||||||
let mut custom_icons = env::vars()
|
let mut custom_icons = env::vars()
|
||||||
.filter_map(|(var, val)| {
|
.filter_map(|(var, val)| {
|
||||||
if let Some(size) = var.strip_prefix("PLUME_LOGO_") {
|
var.strip_prefix("PLUME_LOGO_")
|
||||||
Some((size.to_owned(), val))
|
.map(|size| (size.to_owned(), val))
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.filter_map(|(var, val)| var.parse::<u64>().ok().map(|var| (var, val)))
|
.filter_map(|(var, val)| var.parse::<u64>().ok().map(|var| (var, val)))
|
||||||
.map(|(dim, src)| Icon {
|
.map(|(dim, src)| Icon {
|
||||||
|
@ -285,7 +285,8 @@ impl List {
|
|||||||
.select(list_elems::word)
|
.select(list_elems::word)
|
||||||
.load::<Option<String>>(conn)
|
.load::<Option<String>>(conn)
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.map(|r| r.into_iter().filter_map(|o| o).collect::<Vec<String>>())
|
// .map(|r| r.into_iter().filter_map(|o| o).collect::<Vec<String>>())
|
||||||
|
.map(|r| r.into_iter().flatten().collect::<Vec<String>>())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(&self, conn: &Connection) -> Result<()> {
|
pub fn clear(&self, conn: &Connection) -> Result<()> {
|
||||||
|
@ -443,13 +443,7 @@ impl Post {
|
|||||||
m,
|
m,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.filter_map(|(id, m)| {
|
.filter_map(|(id, m)| id.map(|id| (m, id)))
|
||||||
if let Some(id) = id {
|
|
||||||
Some((m, id))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let old_mentions = Mention::list_for_post(&conn, self.id)?;
|
let old_mentions = Mention::list_for_post(&conn, self.id)?;
|
||||||
|
@ -17,24 +17,22 @@ pub struct RemoteFetchActor {
|
|||||||
|
|
||||||
impl RemoteFetchActor {
|
impl RemoteFetchActor {
|
||||||
pub fn init(conn: DbPool) {
|
pub fn init(conn: DbPool) {
|
||||||
ACTOR_SYS
|
let actor = ACTOR_SYS
|
||||||
.actor_of_args::<RemoteFetchActor, _>("remote-fetch", conn)
|
.actor_of_args::<RemoteFetchActor, _>("remote-fetch", conn)
|
||||||
.expect("Failed to initialize remote fetch actor");
|
.expect("Failed to initialize remote fetch actor");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Actor for RemoteFetchActor {
|
|
||||||
type Msg = UserEvent;
|
|
||||||
|
|
||||||
fn pre_start(&mut self, ctx: &Context<Self::Msg>) {
|
|
||||||
USER_CHAN.tell(
|
USER_CHAN.tell(
|
||||||
Subscribe {
|
Subscribe {
|
||||||
actor: Box::new(ctx.myself()),
|
actor: Box::new(actor),
|
||||||
topic: "*".into(),
|
topic: "*".into(),
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Actor for RemoteFetchActor {
|
||||||
|
type Msg = UserEvent;
|
||||||
|
|
||||||
fn recv(&mut self, _ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) {
|
fn recv(&mut self, _ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) {
|
||||||
use UserEvent::*;
|
use UserEvent::*;
|
||||||
|
@ -156,7 +156,7 @@ impl<'de> Deserialize<'de> for SafeString {
|
|||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
Ok(deserializer.deserialize_string(SafeStringVisitor)?)
|
deserializer.deserialize_string(SafeStringVisitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,24 +13,22 @@ pub struct SearchActor {
|
|||||||
|
|
||||||
impl SearchActor {
|
impl SearchActor {
|
||||||
pub fn init(searcher: Arc<Searcher>, conn: DbPool) {
|
pub fn init(searcher: Arc<Searcher>, conn: DbPool) {
|
||||||
ACTOR_SYS
|
let actor = ACTOR_SYS
|
||||||
.actor_of_args::<SearchActor, _>("search", (searcher, conn))
|
.actor_of_args::<SearchActor, _>("search", (searcher, conn))
|
||||||
.expect("Failed to initialize searcher actor");
|
.expect("Failed to initialize searcher actor");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Actor for SearchActor {
|
|
||||||
type Msg = PostEvent;
|
|
||||||
|
|
||||||
fn pre_start(&mut self, ctx: &Context<Self::Msg>) {
|
|
||||||
POST_CHAN.tell(
|
POST_CHAN.tell(
|
||||||
Subscribe {
|
Subscribe {
|
||||||
actor: Box::new(ctx.myself()),
|
actor: Box::new(actor),
|
||||||
topic: "*".into(),
|
topic: "*".into(),
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Actor for SearchActor {
|
||||||
|
type Msg = PostEvent;
|
||||||
|
|
||||||
fn recv(&mut self, _ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) {
|
fn recv(&mut self, _ctx: &Context<Self::Msg>, msg: Self::Msg, _sender: Sender) {
|
||||||
use PostEvent::*;
|
use PostEvent::*;
|
||||||
|
@ -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>)> {
|
fn parse_m<'a, 'b>(mut stream: &'b [Token<'a>]) -> QueryResult<(&'b [Token<'a>], Vec<&'a str>)> {
|
||||||
let mut res: Vec<&str> = Vec::new();
|
let mut res: Vec<&str> = vec![match stream.get(0)? {
|
||||||
res.push(match stream.get(0)? {
|
|
||||||
Token::Word(_, _, w) => w,
|
Token::Word(_, _, w) => w,
|
||||||
t => return t.get_error(Token::Word(0, 0, "any word")),
|
t => return t.get_error(Token::Word(0, 0, "any word")),
|
||||||
});
|
}];
|
||||||
stream = &stream[1..];
|
stream = &stream[1..];
|
||||||
while let Token::Comma(_) = stream[0] {
|
while let Token::Comma(_) = stream[0] {
|
||||||
res.push(match stream.get(1)? {
|
res.push(match stream.get(1)? {
|
||||||
|
@ -486,10 +486,7 @@ impl User {
|
|||||||
.filter_map(|j| serde_json::from_value(j.clone()).ok())
|
.filter_map(|j| serde_json::from_value(j.clone()).ok())
|
||||||
.collect::<Vec<T>>();
|
.collect::<Vec<T>>();
|
||||||
|
|
||||||
let next = match json.get("next") {
|
let next = json.get("next").map(|x| x.as_str().unwrap().to_owned());
|
||||||
Some(x) => Some(x.as_str().unwrap().to_owned()),
|
|
||||||
None => None,
|
|
||||||
};
|
|
||||||
Ok((items, next))
|
Ok((items, next))
|
||||||
}
|
}
|
||||||
pub fn fetch_outbox<T: Activity>(&self) -> Result<Vec<T>> {
|
pub fn fetch_outbox<T: Activity>(&self) -> Result<Vec<T>> {
|
||||||
|
@ -1 +1 @@
|
|||||||
nightly-2021-01-15
|
nightly-2021-03-25
|
||||||
|
@ -25,7 +25,7 @@ parts:
|
|||||||
plume:
|
plume:
|
||||||
plugin: rust
|
plugin: rust
|
||||||
source: .
|
source: .
|
||||||
rust-revision: nightly-2020-01-15
|
rust-revision: nightly-2021-03-25
|
||||||
build-packages:
|
build-packages:
|
||||||
- libssl-dev
|
- libssl-dev
|
||||||
- pkg-config
|
- pkg-config
|
||||||
|
@ -348,7 +348,7 @@ pub fn update(
|
|||||||
#[get("/~/<name>/outbox")]
|
#[get("/~/<name>/outbox")]
|
||||||
pub fn outbox(name: String, conn: DbConn) -> Option<ActivityStream<OrderedCollection>> {
|
pub fn outbox(name: String, conn: DbConn) -> Option<ActivityStream<OrderedCollection>> {
|
||||||
let blog = Blog::find_by_fqn(&conn, &name).ok()?;
|
let blog = Blog::find_by_fqn(&conn, &name).ok()?;
|
||||||
Some(blog.outbox(&conn).ok()?)
|
blog.outbox(&conn).ok()
|
||||||
}
|
}
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
#[get("/~/<name>/outbox?<page>")]
|
#[get("/~/<name>/outbox?<page>")]
|
||||||
@ -358,7 +358,7 @@ pub fn outbox_page(
|
|||||||
conn: DbConn,
|
conn: DbConn,
|
||||||
) -> Option<ActivityStream<OrderedCollectionPage>> {
|
) -> Option<ActivityStream<OrderedCollectionPage>> {
|
||||||
let blog = Blog::find_by_fqn(&conn, &name).ok()?;
|
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("/~/<name>/atom.xml")]
|
#[get("/~/<name>/atom.xml")]
|
||||||
pub fn atom_feed(name: String, conn: DbConn) -> Option<Content<String>> {
|
pub fn atom_feed(name: String, conn: DbConn) -> Option<Content<String>> {
|
||||||
|
Loading…
Reference in New Issue
Block a user