insert_activity,
objects::{community::ApubCommunity, person::ApubPerson, post::ApubPost},
protocol::{
- activities::{
- community::{collection_add::CollectionAdd, collection_remove::CollectionRemove},
- create_or_update::page::CreateOrUpdatePage,
- CreateOrUpdateType,
- },
+ activities::community::{collection_add::CollectionAdd, collection_remove::CollectionRemove},
InCommunity,
},
SendActivity,
community::{AddModToCommunity, AddModToCommunityResponse},
context::LemmyContext,
post::{FeaturePost, PostResponse},
- utils::{generate_featured_url, generate_moderators_url, get_local_user_view_from_jwt},
+ utils::{generate_featured_url, generate_moderators_url, local_user_view_from_jwt},
};
use lemmy_db_schema::{
impls::community::CollectionType,
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
insert_activity(&self.id, &self, false, false, context).await?;
let (community, collection_type) =
- Community::get_by_collection_url(context.pool(), &self.target.into()).await?;
+ Community::get_by_collection_url(&mut context.pool(), &self.target.into()).await?;
match collection_type {
CollectionType::Moderators => {
let new_mod = ObjectId::<ApubPerson>::from(self.object)
// been added. Skip it here as it would result in a duplicate key error.
let new_mod_id = new_mod.id;
let moderated_communities =
- CommunityModerator::get_person_moderated_communities(context.pool(), new_mod_id).await?;
+ CommunityModerator::get_person_moderated_communities(&mut context.pool(), new_mod_id)
+ .await?;
if !moderated_communities.contains(&community.id) {
let form = CommunityModeratorForm {
community_id: community.id,
person_id: new_mod.id,
};
- CommunityModerator::join(context.pool(), &form).await?;
+ CommunityModerator::join(&mut context.pool(), &form).await?;
// write mod log
let actor = self.actor.dereference(context).await?;
community_id: community.id,
removed: Some(false),
};
- ModAddCommunity::create(context.pool(), &form).await?;
+ ModAddCommunity::create(&mut context.pool(), &form).await?;
}
// TODO: send websocket notification about added mod
}
let form = PostUpdateForm::builder()
.featured_community(Some(true))
.build();
- Post::update(context.pool(), post.id, &form).await?;
+ Post::update(&mut context.pool(), post.id, &form).await?;
}
}
Ok(())
_response: &Self::Response,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
- let community: ApubCommunity = Community::read(context.pool(), request.community_id)
+ let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+ let community: ApubCommunity = Community::read(&mut context.pool(), request.community_id)
.await?
.into();
- let updated_mod: ApubPerson = Person::read(context.pool(), request.person_id)
+ let updated_mod: ApubPerson = Person::read(&mut context.pool(), request.person_id)
.await?
.into();
if request.added {
response: &Self::Response,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
- let local_user_view =
- get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?;
- // Deprecated, for backwards compatibility with 0.17
- CreateOrUpdatePage::send(
- &response.post_view.post,
- local_user_view.person.id,
- CreateOrUpdateType::Update,
- context,
- )
- .await?;
- let community = Community::read(context.pool(), response.post_view.community.id)
+ let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
+ let community = Community::read(&mut context.pool(), response.post_view.community.id)
.await?
.into();
let post = response.post_view.post.clone().into();