Change '&' to '&mut'.
Key changes:
* `find plume-models -name '*.rs' -exec sed -i -e 's/&PlumeRocket/\&mut PlumeRocket/' '{}' \;`
* Remove `let conn = &*rockets.conn;` lines
* Change `conn` to `&mut *rockets.conn` where `conn` was used
This commit is contained in:
@@ -132,7 +132,7 @@ impl Blog {
|
||||
.map_err(Error::from)
|
||||
}
|
||||
|
||||
pub async fn find_by_fqn(c: &PlumeRocket, fqn: &str) -> Result<Blog> {
|
||||
pub async fn find_by_fqn(c: &mut PlumeRocket, fqn: &str) -> Result<Blog> {
|
||||
let from_db = blogs::table
|
||||
.filter(blogs::fqn.eq(fqn))
|
||||
.first(&*c.conn)
|
||||
@@ -144,7 +144,7 @@ impl Blog {
|
||||
}
|
||||
}
|
||||
|
||||
async fn fetch_from_webfinger(c: &PlumeRocket, acct: &str) -> Result<Blog> {
|
||||
async fn fetch_from_webfinger(c: &mut PlumeRocket, acct: &str) -> Result<Blog> {
|
||||
resolve_with_prefix(Prefix::Group, acct.to_owned(), true)
|
||||
.await?
|
||||
.links
|
||||
@@ -340,11 +340,11 @@ impl FromId<PlumeRocket> for Blog {
|
||||
type Error = Error;
|
||||
type Object = CustomGroup;
|
||||
|
||||
fn from_db(c: &PlumeRocket, id: &str) -> Result<Self> {
|
||||
fn from_db(c: &mut PlumeRocket, id: &str) -> Result<Self> {
|
||||
Self::find_by_ap_url(&c.conn, id)
|
||||
}
|
||||
|
||||
fn from_activity(c: &PlumeRocket, acct: CustomGroup) -> Result<Self> {
|
||||
fn from_activity(c: &mut PlumeRocket, acct: CustomGroup) -> Result<Self> {
|
||||
let url = Url::parse(&acct.object.object_props.id_string()?)?;
|
||||
let inst = url.host_str()?;
|
||||
let instance = Instance::find_by_domain(&c.conn, inst).or_else(|_| {
|
||||
@@ -436,7 +436,7 @@ impl FromId<PlumeRocket> for Blog {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsActor<&PlumeRocket> for Blog {
|
||||
impl AsActor<&mut PlumeRocket> for Blog {
|
||||
fn get_inbox_url(&self) -> String {
|
||||
self.inbox_url.clone()
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ impl Comment {
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub async fn to_activity(&self, c: &PlumeRocket) -> Result<Note> {
|
||||
pub async fn to_activity(&self, c: &mut PlumeRocket) -> Result<Note> {
|
||||
let author = User::get(&c.conn, self.author_id)?;
|
||||
let (html, mentions, _hashtags) = utils::md_to_html(
|
||||
self.content.get().as_ref(),
|
||||
@@ -140,7 +140,7 @@ impl Comment {
|
||||
Ok(note)
|
||||
}
|
||||
|
||||
pub async fn create_activity(&self, c: &PlumeRocket) -> Result<Create> {
|
||||
pub async fn create_activity(&self, c: &mut PlumeRocket) -> Result<Create> {
|
||||
let author = User::get(&c.conn, self.author_id)?;
|
||||
|
||||
let note = self.to_activity(c).await?;
|
||||
@@ -198,11 +198,11 @@ impl FromId<PlumeRocket> for Comment {
|
||||
type Error = Error;
|
||||
type Object = Note;
|
||||
|
||||
fn from_db(c: &PlumeRocket, id: &str) -> Result<Self> {
|
||||
fn from_db(c: &mut PlumeRocket, id: &str) -> Result<Self> {
|
||||
Self::find_by_ap_url(&c.conn, id)
|
||||
}
|
||||
|
||||
fn from_activity(c: &PlumeRocket, note: Note) -> Result<Self> {
|
||||
fn from_activity(c: &mut PlumeRocket, note: Note) -> Result<Self> {
|
||||
let conn = &*c.conn;
|
||||
let comm = {
|
||||
let previous_url = note.object_props.in_reply_to.as_ref()?.as_str()?;
|
||||
@@ -322,21 +322,21 @@ impl FromId<PlumeRocket> for Comment {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Create, &PlumeRocket> for Comment {
|
||||
impl AsObject<User, Create, &mut PlumeRocket> for Comment {
|
||||
type Error = Error;
|
||||
type Output = Self;
|
||||
|
||||
fn activity(self, _c: &PlumeRocket, _actor: User, _id: &str) -> Result<Self> {
|
||||
fn activity(self, _c: &mut PlumeRocket, _actor: User, _id: &str) -> Result<Self> {
|
||||
// The actual creation takes place in the FromId impl
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Delete, &PlumeRocket> for Comment {
|
||||
impl AsObject<User, Delete, &mut PlumeRocket> for Comment {
|
||||
type Error = Error;
|
||||
type Output = ();
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
if self.author_id != actor.id {
|
||||
return Err(Error::Unauthorized);
|
||||
}
|
||||
|
||||
@@ -136,11 +136,11 @@ impl Follow {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, FollowAct, &PlumeRocket> for User {
|
||||
impl AsObject<User, FollowAct, &mut PlumeRocket> for User {
|
||||
type Error = Error;
|
||||
type Output = Follow;
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, id: &str) -> Result<Follow> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, id: &str) -> Result<Follow> {
|
||||
// Mastodon (at least) requires the full Follow object when accepting it,
|
||||
// so we rebuilt it here
|
||||
let mut follow = FollowAct::default();
|
||||
@@ -156,11 +156,11 @@ impl FromId<PlumeRocket> for Follow {
|
||||
type Error = Error;
|
||||
type Object = FollowAct;
|
||||
|
||||
fn from_db(c: &PlumeRocket, id: &str) -> Result<Self> {
|
||||
fn from_db(c: &mut PlumeRocket, id: &str) -> Result<Self> {
|
||||
Follow::find_by_ap_url(&c.conn, id)
|
||||
}
|
||||
|
||||
fn from_activity(c: &PlumeRocket, follow: FollowAct) -> Result<Self> {
|
||||
fn from_activity(c: &mut PlumeRocket, follow: FollowAct) -> Result<Self> {
|
||||
let actor =
|
||||
User::from_id(c, &follow.follow_props.actor_link::<Id>()?, None).map_err(|(_, e)| e)?;
|
||||
|
||||
@@ -170,11 +170,11 @@ impl FromId<PlumeRocket> for Follow {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Undo, &PlumeRocket> for Follow {
|
||||
impl AsObject<User, Undo, &mut PlumeRocket> for Follow {
|
||||
type Error = Error;
|
||||
type Output = ();
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
let conn = &*c.conn;
|
||||
if self.follower_id == actor.id {
|
||||
diesel::delete(&self).execute(conn)?;
|
||||
|
||||
@@ -45,7 +45,7 @@ impl_into_inbox_result! {
|
||||
Reshare => Reshared
|
||||
}
|
||||
|
||||
pub fn inbox(ctx: &PlumeRocket, act: serde_json::Value) -> Result<InboxResult, Error> {
|
||||
pub fn inbox(ctx: &mut PlumeRocket, act: serde_json::Value) -> Result<InboxResult, Error> {
|
||||
Inbox::handle(ctx, act)
|
||||
.with::<User, Announce, Post>()
|
||||
.with::<User, Create, Comment>()
|
||||
@@ -72,7 +72,7 @@ pub(crate) mod tests {
|
||||
use diesel::Connection;
|
||||
|
||||
pub fn fill_database(
|
||||
rockets: &PlumeRocket,
|
||||
rockets: &mut PlumeRocket,
|
||||
) -> (
|
||||
Vec<crate::posts::Post>,
|
||||
Vec<crate::users::User>,
|
||||
|
||||
@@ -83,11 +83,11 @@ impl Like {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, activity::Like, &PlumeRocket> for Post {
|
||||
impl AsObject<User, activity::Like, &mut PlumeRocket> for Post {
|
||||
type Error = Error;
|
||||
type Output = Like;
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, id: &str) -> Result<Like> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, id: &str) -> Result<Like> {
|
||||
let res = Like::insert(
|
||||
&c.conn,
|
||||
NewLike {
|
||||
@@ -107,11 +107,11 @@ impl FromId<PlumeRocket> for Like {
|
||||
type Error = Error;
|
||||
type Object = activity::Like;
|
||||
|
||||
fn from_db(c: &PlumeRocket, id: &str) -> Result<Self> {
|
||||
fn from_db(c: &mut PlumeRocket, id: &str) -> Result<Self> {
|
||||
Like::find_by_ap_url(&c.conn, id)
|
||||
}
|
||||
|
||||
fn from_activity(c: &PlumeRocket, act: activity::Like) -> Result<Self> {
|
||||
fn from_activity(c: &mut PlumeRocket, act: activity::Like) -> Result<Self> {
|
||||
let res = Like::insert(
|
||||
&c.conn,
|
||||
NewLike {
|
||||
@@ -129,11 +129,11 @@ impl FromId<PlumeRocket> for Like {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, activity::Undo, &PlumeRocket> for Like {
|
||||
impl AsObject<User, activity::Undo, &mut PlumeRocket> for Like {
|
||||
type Error = Error;
|
||||
type Output = ();
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
let conn = &*c.conn;
|
||||
if actor.id == self.user_id {
|
||||
diesel::delete(&self).execute(conn)?;
|
||||
|
||||
+17
-16
@@ -197,8 +197,7 @@ impl Media {
|
||||
}
|
||||
|
||||
// TODO: merge with save_remote?
|
||||
pub async fn from_activity(c: &PlumeRocket, image: &Image) -> Result<Media> {
|
||||
let conn = &*c.conn;
|
||||
pub async fn from_activity(c: &mut PlumeRocket, image: &Image) -> Result<Media> {
|
||||
let remote_url = image.object_props.url_string().ok()?;
|
||||
let ext = remote_url
|
||||
.rsplit('.')
|
||||
@@ -215,8 +214,22 @@ impl Media {
|
||||
let contents = reqwest::get(remote_url.as_str()).await?.bytes().await?;
|
||||
dest.write_all(&contents).await?;
|
||||
|
||||
let owner_id = User::from_id(
|
||||
c,
|
||||
image
|
||||
.object_props
|
||||
.attributed_to_link_vec::<Id>()
|
||||
.ok()?
|
||||
.into_iter()
|
||||
.next()?
|
||||
.as_ref(),
|
||||
None,
|
||||
)
|
||||
.map_err(|(_, e)| e)?
|
||||
.id;
|
||||
|
||||
Media::insert(
|
||||
conn,
|
||||
&mut c.conn,
|
||||
NewMedia {
|
||||
file_path: path.to_str()?.to_string(),
|
||||
alt_text: image.object_props.content_string().ok()?,
|
||||
@@ -224,19 +237,7 @@ impl Media {
|
||||
remote_url: None,
|
||||
sensitive: image.object_props.summary_string().is_ok(),
|
||||
content_warning: image.object_props.summary_string().ok(),
|
||||
owner_id: User::from_id(
|
||||
c,
|
||||
image
|
||||
.object_props
|
||||
.attributed_to_link_vec::<Id>()
|
||||
.ok()?
|
||||
.into_iter()
|
||||
.next()?
|
||||
.as_ref(),
|
||||
None,
|
||||
)
|
||||
.map_err(|(_, e)| e)?
|
||||
.id,
|
||||
owner_id
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ impl Mention {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn build_activity(c: &PlumeRocket, ment: &str) -> Result<link::Mention> {
|
||||
pub async fn build_activity(c: &mut PlumeRocket, ment: &str) -> Result<link::Mention> {
|
||||
let user = User::find_by_fqn(c, ment).await?;
|
||||
let mut mention = link::Mention::default();
|
||||
mention.link_props.set_href_string(user.ap_url)?;
|
||||
|
||||
+18
-19
@@ -554,12 +554,11 @@ impl FromId<PlumeRocket> for Post {
|
||||
type Error = Error;
|
||||
type Object = LicensedArticle;
|
||||
|
||||
fn from_db(c: &PlumeRocket, id: &str) -> Result<Self> {
|
||||
fn from_db(c: &mut PlumeRocket, id: &str) -> Result<Self> {
|
||||
Self::find_by_ap_url(&c.conn, id)
|
||||
}
|
||||
|
||||
fn from_activity(c: &PlumeRocket, article: LicensedArticle) -> Result<Self> {
|
||||
let conn = &*c.conn;
|
||||
fn from_activity(c: &mut PlumeRocket, article: LicensedArticle) -> Result<Self> {
|
||||
let searcher = &c.searcher;
|
||||
let license = article.custom_props.license_string().unwrap_or_default();
|
||||
let article = article.object;
|
||||
@@ -570,12 +569,12 @@ impl FromId<PlumeRocket> for Post {
|
||||
.into_iter()
|
||||
.fold((None, vec![]), |(blog, mut authors), link| {
|
||||
let url = link;
|
||||
match User::from_id(&c, &url, None) {
|
||||
match User::from_id(&mut c, &url, None) {
|
||||
Ok(u) => {
|
||||
authors.push(u);
|
||||
(blog, authors)
|
||||
}
|
||||
Err(_) => (blog.or_else(|| Blog::from_id(&c, &url, None).ok()), authors),
|
||||
Err(_) => (blog.or_else(|| Blog::from_id(&mut c, &url, None).ok()), authors),
|
||||
}
|
||||
});
|
||||
|
||||
@@ -583,11 +582,11 @@ impl FromId<PlumeRocket> for Post {
|
||||
|
||||
let mut r = Runtime::new().unwrap();
|
||||
let cover =
|
||||
Some(r.block_on(async { Media::from_activity(&c, &image).await.ok().unwrap().id }));
|
||||
Some(r.block_on(async { Media::from_activity(&mut c, &image).await.ok().unwrap().id }));
|
||||
|
||||
let title = article.object_props.name_string()?;
|
||||
let post = Post::insert(
|
||||
conn,
|
||||
&mut c.conn,
|
||||
NewPost {
|
||||
blog_id: blog?.id,
|
||||
slug: title.to_kebab_case(),
|
||||
@@ -610,7 +609,7 @@ impl FromId<PlumeRocket> for Post {
|
||||
|
||||
for author in authors {
|
||||
PostAuthor::insert(
|
||||
conn,
|
||||
&mut c.conn,
|
||||
NewPostAuthor {
|
||||
post_id: post.id,
|
||||
author_id: author.id,
|
||||
@@ -627,7 +626,7 @@ impl FromId<PlumeRocket> for Post {
|
||||
if let Some(serde_json::Value::Array(tags)) = article.object_props.tag {
|
||||
for tag in tags {
|
||||
serde_json::from_value::<link::Mention>(tag.clone())
|
||||
.map(|m| Mention::from_activity(conn, &m, post.id, true, true))
|
||||
.map(|m| Mention::from_activity(&mut c.conn, &m, post.id, true, true))
|
||||
.ok();
|
||||
|
||||
serde_json::from_value::<Hashtag>(tag.clone())
|
||||
@@ -635,7 +634,7 @@ impl FromId<PlumeRocket> for Post {
|
||||
.and_then(|t| {
|
||||
let tag_name = t.name_string()?;
|
||||
Ok(Tag::from_activity(
|
||||
conn,
|
||||
&mut c.conn,
|
||||
&t,
|
||||
post.id,
|
||||
hashtags.remove(&tag_name),
|
||||
@@ -651,21 +650,21 @@ impl FromId<PlumeRocket> for Post {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Create, &PlumeRocket> for Post {
|
||||
impl AsObject<User, Create, &mut PlumeRocket> for Post {
|
||||
type Error = Error;
|
||||
type Output = Post;
|
||||
|
||||
fn activity(self, _c: &PlumeRocket, _actor: User, _id: &str) -> Result<Post> {
|
||||
fn activity(self, _c: &mut PlumeRocket, _actor: User, _id: &str) -> Result<Post> {
|
||||
// TODO: check that _actor is actually one of the author?
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Delete, &PlumeRocket> for Post {
|
||||
impl AsObject<User, Delete, &mut PlumeRocket> for Post {
|
||||
type Error = Error;
|
||||
type Output = ();
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
let can_delete = self
|
||||
.get_authors(&c.conn)?
|
||||
.into_iter()
|
||||
@@ -693,12 +692,12 @@ impl FromId<PlumeRocket> for PostUpdate {
|
||||
type Error = Error;
|
||||
type Object = LicensedArticle;
|
||||
|
||||
fn from_db(_: &PlumeRocket, _: &str) -> Result<Self> {
|
||||
fn from_db(_: &mut PlumeRocket, _: &str) -> Result<Self> {
|
||||
// Always fail because we always want to deserialize the AP object
|
||||
Err(Error::NotFound)
|
||||
}
|
||||
|
||||
fn from_activity(c: &PlumeRocket, updated: LicensedArticle) -> Result<Self> {
|
||||
fn from_activity(c: &mut PlumeRocket, updated: LicensedArticle) -> Result<Self> {
|
||||
let image = updated
|
||||
.object
|
||||
.object_props
|
||||
@@ -707,7 +706,7 @@ impl FromId<PlumeRocket> for PostUpdate {
|
||||
.unwrap();
|
||||
let mut r = Runtime::new().unwrap();
|
||||
let cover =
|
||||
Some(r.block_on(async { Media::from_activity(&c, &image).await.ok().unwrap().id }));
|
||||
Some(r.block_on(async { Media::from_activity(&mut c, &image).await.ok().unwrap().id }));
|
||||
|
||||
Ok(PostUpdate {
|
||||
ap_url: updated.object.object_props.id_string()?,
|
||||
@@ -727,11 +726,11 @@ impl FromId<PlumeRocket> for PostUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Update, &PlumeRocket> for PostUpdate {
|
||||
impl AsObject<User, Update, &mut PlumeRocket> for PostUpdate {
|
||||
type Error = Error;
|
||||
type Output = ();
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
let conn = &*c.conn;
|
||||
let searcher = &c.searcher;
|
||||
let mut post = Post::from_id(c, &self.ap_url, None).map_err(|(_, e)| e)?;
|
||||
|
||||
@@ -107,11 +107,11 @@ impl Reshare {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Announce, &PlumeRocket> for Post {
|
||||
impl AsObject<User, Announce, &mut PlumeRocket> for Post {
|
||||
type Error = Error;
|
||||
type Output = Reshare;
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, id: &str) -> Result<Reshare> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, id: &str) -> Result<Reshare> {
|
||||
let conn = &*c.conn;
|
||||
let reshare = Reshare::insert(
|
||||
conn,
|
||||
@@ -132,11 +132,11 @@ impl FromId<PlumeRocket> for Reshare {
|
||||
type Error = Error;
|
||||
type Object = Announce;
|
||||
|
||||
fn from_db(c: &PlumeRocket, id: &str) -> Result<Self> {
|
||||
fn from_db(c: &mut PlumeRocket, id: &str) -> Result<Self> {
|
||||
Reshare::find_by_ap_url(&c.conn, id)
|
||||
}
|
||||
|
||||
fn from_activity(c: &PlumeRocket, act: Announce) -> Result<Self> {
|
||||
fn from_activity(c: &mut PlumeRocket, act: Announce) -> Result<Self> {
|
||||
let res = Reshare::insert(
|
||||
&c.conn,
|
||||
NewReshare {
|
||||
@@ -154,11 +154,11 @@ impl FromId<PlumeRocket> for Reshare {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Undo, &PlumeRocket> for Reshare {
|
||||
impl AsObject<User, Undo, &mut PlumeRocket> for Reshare {
|
||||
type Error = Error;
|
||||
type Output = ();
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
let conn = &*c.conn;
|
||||
if actor.id == self.user_id {
|
||||
diesel::delete(&self).execute(conn)?;
|
||||
|
||||
@@ -208,7 +208,7 @@ impl Timeline {
|
||||
.map_err(Error::from)
|
||||
}
|
||||
|
||||
pub fn add_to_all_timelines(rocket: &PlumeRocket, post: &Post, kind: Kind<'_>) -> Result<()> {
|
||||
pub fn add_to_all_timelines(rocket: &mut PlumeRocket, post: &Post, kind: Kind<'_>) -> Result<()> {
|
||||
let timelines = timeline_definition::table
|
||||
.load::<Self>(rocket.conn.deref())
|
||||
.map_err(Error::from)?;
|
||||
@@ -231,7 +231,7 @@ impl Timeline {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn matches(&self, rocket: &PlumeRocket, post: &Post, kind: Kind<'_>) -> Result<bool> {
|
||||
pub fn matches(&self, rocket: &mut PlumeRocket, post: &Post, kind: Kind<'_>) -> Result<bool> {
|
||||
let query = TimelineQuery::parse(&self.query)?;
|
||||
query.matches(rocket, self, post, kind)
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ enum TQ<'a> {
|
||||
impl<'a> TQ<'a> {
|
||||
fn matches(
|
||||
&self,
|
||||
rocket: &PlumeRocket,
|
||||
rocket: &mut PlumeRocket,
|
||||
timeline: &Timeline,
|
||||
post: &Post,
|
||||
kind: Kind<'_>,
|
||||
@@ -207,7 +207,7 @@ enum Arg<'a> {
|
||||
impl<'a> Arg<'a> {
|
||||
pub fn matches(
|
||||
&self,
|
||||
rocket: &PlumeRocket,
|
||||
rocket: &mut PlumeRocket,
|
||||
timeline: &Timeline,
|
||||
post: &Post,
|
||||
kind: Kind<'_>,
|
||||
@@ -232,7 +232,7 @@ enum WithList {
|
||||
impl WithList {
|
||||
pub fn matches(
|
||||
&self,
|
||||
rocket: &PlumeRocket,
|
||||
rocket: &mut PlumeRocket,
|
||||
timeline: &Timeline,
|
||||
post: &Post,
|
||||
list: &List<'_>,
|
||||
@@ -391,7 +391,7 @@ enum Bool {
|
||||
impl Bool {
|
||||
pub fn matches(
|
||||
&self,
|
||||
rocket: &PlumeRocket,
|
||||
rocket: &mut PlumeRocket,
|
||||
timeline: &Timeline,
|
||||
post: &Post,
|
||||
kind: Kind<'_>,
|
||||
@@ -662,7 +662,7 @@ impl<'a> TimelineQuery<'a> {
|
||||
|
||||
pub fn matches(
|
||||
&self,
|
||||
rocket: &PlumeRocket,
|
||||
rocket: &mut PlumeRocket,
|
||||
timeline: &Timeline,
|
||||
post: &Post,
|
||||
kind: Kind<'_>,
|
||||
|
||||
@@ -189,7 +189,7 @@ impl User {
|
||||
.map_err(Error::from)
|
||||
}
|
||||
|
||||
pub async fn find_by_fqn(c: &PlumeRocket, fqn: &str) -> Result<User> {
|
||||
pub async fn find_by_fqn(c: &mut PlumeRocket, fqn: &str) -> Result<User> {
|
||||
let from_db = users::table
|
||||
.filter(users::fqn.eq(fqn))
|
||||
.first(&*c.conn)
|
||||
@@ -201,7 +201,7 @@ impl User {
|
||||
}
|
||||
}
|
||||
|
||||
async fn fetch_from_webfinger(c: &PlumeRocket, acct: &str) -> Result<User> {
|
||||
async fn fetch_from_webfinger(c: &mut PlumeRocket, acct: &str) -> Result<User> {
|
||||
let link = resolve(acct.to_owned(), true)
|
||||
.await?
|
||||
.links
|
||||
@@ -245,7 +245,7 @@ impl User {
|
||||
Ok(json)
|
||||
}
|
||||
|
||||
pub async fn fetch_from_url(c: &PlumeRocket, url: &str) -> Result<User> {
|
||||
pub async fn fetch_from_url(c: &mut PlumeRocket, url: &str) -> Result<User> {
|
||||
let json = User::fetch(url).await?;
|
||||
User::from_activity(c, json)
|
||||
}
|
||||
@@ -821,11 +821,11 @@ impl FromId<PlumeRocket> for User {
|
||||
type Error = Error;
|
||||
type Object = CustomPerson;
|
||||
|
||||
fn from_db(c: &PlumeRocket, id: &str) -> Result<Self> {
|
||||
fn from_db(c: &mut PlumeRocket, id: &str) -> Result<Self> {
|
||||
Self::find_by_ap_url(&c.conn, id)
|
||||
}
|
||||
|
||||
fn from_activity(c: &PlumeRocket, acct: CustomPerson) -> Result<Self> {
|
||||
fn from_activity(c: &mut PlumeRocket, acct: CustomPerson) -> Result<Self> {
|
||||
let url = Url::parse(&acct.object.object_props.id_string()?)?;
|
||||
let inst = url.host_str()?;
|
||||
let instance = Instance::find_by_domain(&c.conn, inst).or_else(|_| {
|
||||
@@ -917,7 +917,7 @@ impl FromId<PlumeRocket> for User {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsActor<&PlumeRocket> for User {
|
||||
impl AsActor<&mut PlumeRocket> for User {
|
||||
fn get_inbox_url(&self) -> String {
|
||||
self.inbox_url.clone()
|
||||
}
|
||||
@@ -933,11 +933,11 @@ impl AsActor<&PlumeRocket> for User {
|
||||
}
|
||||
}
|
||||
|
||||
impl AsObject<User, Delete, &PlumeRocket> for User {
|
||||
impl AsObject<User, Delete, &mut PlumeRocket> for User {
|
||||
type Error = Error;
|
||||
type Output = ();
|
||||
|
||||
fn activity(self, c: &PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
fn activity(self, c: &mut PlumeRocket, actor: User, _id: &str) -> Result<()> {
|
||||
if self.id == actor.id {
|
||||
self.delete(&c.conn, &c.searcher).map(|_| ())
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user