Revert "Add blank lines under each line with conn ="

This reverts commit 773a6d3beb.
This commit is contained in:
dull b 2023-06-30 18:23:40 +00:00
parent 3021e2c9b8
commit c1c17ab63b
137 changed files with 6 additions and 206 deletions

View File

@ -19,7 +19,6 @@ impl Perform for SaveComment {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &SaveComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -26,7 +26,6 @@ impl Perform for CreateCommentReport {
context: &Data<LemmyContext>,
) -> Result<CommentReportResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreateCommentReport = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -20,7 +20,6 @@ impl Perform for ResolveCommentReport {
context: &Data<LemmyContext>,
) -> Result<CommentReportResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &ResolveCommentReport = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -25,7 +25,6 @@ impl Perform for AddModToCommunity {
context: &Data<LemmyContext>,
) -> Result<AddModToCommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &AddModToCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -33,7 +33,6 @@ impl Perform for BanFromCommunity {
context: &Data<LemmyContext>,
) -> Result<BanFromCommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &BanFromCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -25,7 +25,6 @@ impl Perform for BlockCommunity {
context: &Data<LemmyContext>,
) -> Result<BlockCommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &BlockCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -22,7 +22,6 @@ impl Perform for FollowCommunity {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &FollowCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -22,7 +22,6 @@ impl Perform for HideCommunity {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &HideCommunity = self;
// Verify its a admin (only admin can hide or unhide it)

View File

@ -28,7 +28,6 @@ impl Perform for TransferCommunity {
context: &Data<LemmyContext>,
) -> Result<GetCommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &TransferCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -70,7 +70,6 @@ mod tests {
#[serial]
async fn test_should_not_validate_user_token_after_password_change() {
let conn = &mut build_db_conn_for_tests().await;
let secret = Secret::init(conn).await.unwrap();
let settings = &SETTINGS.to_owned();

View File

@ -22,7 +22,6 @@ impl Perform for AddAdmin {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<AddAdminResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &AddAdmin = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -25,7 +25,6 @@ impl Perform for BanPerson {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<BanPersonResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &BanPerson = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -19,7 +19,6 @@ impl Perform for BlockPerson {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<BlockPersonResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &BlockPerson = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -16,7 +16,6 @@ impl Perform for ChangePassword {
#[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &ChangePassword = self;
let local_user_view = local_user_view_from_jwt(data.auth.as_ref(), context).await?;

View File

@ -19,7 +19,6 @@ impl Perform for PasswordChangeAfterReset {
#[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &PasswordChangeAfterReset = self;
// Fetch the user_id from the token

View File

@ -18,7 +18,6 @@ impl Perform for GetCaptcha {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let local_site = LocalSite::read(&mut conn).await?;
if !local_site.captcha_enabled {

View File

@ -14,7 +14,6 @@ impl Perform for GetBannedPersons {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data: &GetBannedPersons = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -16,7 +16,6 @@ impl Perform for Login {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &Login = self;
let site_view = SiteView::read_local(&mut conn).await?;

View File

@ -28,7 +28,6 @@ impl Perform for GetPersonMentions {
let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
let mut conn = context.conn().await?;
let mentions = PersonMentionQuery::builder()
.conn(&mut conn)
.recipient_id(person_id)

View File

@ -25,7 +25,6 @@ impl Perform for GetReplies {
let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts);
let mut conn = context.conn().await?;
let replies = CommentReplyQuery::builder()
.conn(&mut conn)
.recipient_id(person_id)

View File

@ -19,7 +19,6 @@ impl Perform for MarkAllAsRead {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetRepliesResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &MarkAllAsRead = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let person_id = local_user_view.person.id;

View File

@ -22,7 +22,6 @@ impl Perform for MarkPersonMentionAsRead {
context: &Data<LemmyContext>,
) -> Result<PersonMentionResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &MarkPersonMentionAsRead = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -22,7 +22,6 @@ impl Perform for MarkCommentReplyAsRead {
context: &Data<LemmyContext>,
) -> Result<CommentReplyResponse, LemmyError> {
let mut conn = context.conn().await?;
let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -16,7 +16,6 @@ impl Perform for GetUnreadCount {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -18,7 +18,6 @@ impl Perform for GetReportCount {
context: &Data<LemmyContext>,
) -> Result<GetReportCountResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &GetReportCount = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -19,7 +19,6 @@ impl Perform for PasswordReset {
context: &Data<LemmyContext>,
) -> Result<PasswordResetResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &PasswordReset = self;
// Fetch that email

View File

@ -34,7 +34,6 @@ impl Perform for SaveUserSettings {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &SaveUserSettings = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let site_view = SiteView::read_local(&mut conn).await?;

View File

@ -19,7 +19,6 @@ impl Perform for VerifyEmail {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let token = self.token.clone();
let verification = EmailVerification::read_for_token(&mut conn, &token)
.await

View File

@ -29,7 +29,6 @@ impl Perform for FeaturePost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &FeaturePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -28,7 +28,6 @@ impl Perform for CreatePostLike {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreatePostLike = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -27,7 +27,6 @@ impl Perform for LockPost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &LockPost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -15,7 +15,6 @@ impl Perform for MarkPostAsRead {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -19,7 +19,6 @@ impl Perform for SavePost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &SavePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -23,7 +23,6 @@ impl Perform for CreatePostReport {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostReportResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreatePostReport = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -30,7 +30,6 @@ impl Perform for ListPostReports {
let page = data.page;
let limit = data.limit;
let mut conn = context.conn().await?;
let post_reports = PostReportQuery::builder()
.conn(&mut conn)
.my_person_id(person_id)

View File

@ -17,7 +17,6 @@ impl Perform for ResolvePostReport {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostReportResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &ResolvePostReport = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -22,7 +22,6 @@ impl Perform for MarkPrivateMessageAsRead {
context: &Data<LemmyContext>,
) -> Result<PrivateMessageResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &MarkPrivateMessageAsRead = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -23,7 +23,6 @@ impl Perform for CreatePrivateMessageReport {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&self.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -22,7 +22,6 @@ impl Perform for ListPrivateMessageReports {
let page = self.page;
let limit = self.limit;
let mut conn = context.conn().await?;
let private_message_reports = PrivateMessageReportQuery::builder()
.conn(&mut conn)
.unresolved_only(unresolved_only)

View File

@ -16,7 +16,6 @@ impl Perform for ResolvePrivateMessageReport {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&self.auth, context).await?;
is_admin(&local_user_view)?;

View File

@ -15,7 +15,6 @@ impl Perform for GetFederatedInstances {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let site_view = SiteView::read_local(&mut conn).await?;
let federated_instances =
build_federated_instances(&site_view.local_site, context.pool()).await?;

View File

@ -26,7 +26,6 @@ impl Perform for LeaveAdmin {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetSiteResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &LeaveAdmin = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -38,7 +38,6 @@ impl Perform for GetModlog {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetModlogResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &GetModlog = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;

View File

@ -21,7 +21,6 @@ impl Perform for PurgeComment {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data: &Self = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -22,7 +22,6 @@ impl Perform for PurgeCommunity {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data: &Self = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -22,7 +22,6 @@ impl Perform for PurgePerson {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data: &Self = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -22,7 +22,6 @@ impl Perform for PurgePost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data: &Self = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -22,7 +22,6 @@ impl Perform for ApproveRegistrationApplication {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -16,7 +16,6 @@ impl Perform for ListRegistrationApplications {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;
@ -30,7 +29,6 @@ impl Perform for ListRegistrationApplications {
let page = data.page;
let limit = data.limit;
let mut conn = context.conn().await?;
let registration_applications = RegistrationApplicationQuery::builder()
.conn(&mut conn)
.unread_only(unread_only)

View File

@ -15,7 +15,6 @@ impl Perform for GetUnreadRegistrationApplicationCount {
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -139,7 +139,6 @@ pub async fn local_user_view_from_jwt(
context: &LemmyContext,
) -> Result<LocalUserView, LemmyError> {
let mut conn = context.conn().await?;
let claims = Claims::decode(jwt, &context.secret().jwt_secret)
.map_err(|e| e.with_message("not_logged_in"))?
.claims;

View File

@ -42,7 +42,6 @@ impl PerformCrud for CreateComment {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreateComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -23,7 +23,6 @@ impl PerformCrud for DeleteComment {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &DeleteComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -16,7 +16,6 @@ impl PerformCrud for GetComment {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<Self::Response, LemmyError> {
let mut conn = context.conn().await?;
let data = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -24,7 +24,6 @@ impl PerformCrud for RemoveComment {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &RemoveComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -32,7 +32,6 @@ impl PerformCrud for EditComment {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommentResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &EditComment = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -47,7 +47,6 @@ impl PerformCrud for CreateCommunity {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreateCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let site_view = SiteView::read_local(&mut conn).await?;

View File

@ -20,7 +20,6 @@ impl PerformCrud for DeleteCommunity {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &DeleteCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -19,7 +19,6 @@ impl PerformCrud for ListCommunities {
context: &Data<LemmyContext>,
) -> Result<ListCommunitiesResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &ListCommunities = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
let local_site = LocalSite::read(&mut conn).await?;
@ -34,7 +33,6 @@ impl PerformCrud for ListCommunities {
let limit = data.limit;
let local_user = local_user_view.map(|l| l.local_user);
let mut conn = context.conn().await?;
let communities = CommunityQuery::builder()
.conn(&mut conn)
.listing_type(listing_type)

View File

@ -22,7 +22,6 @@ impl PerformCrud for RemoveCommunity {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &RemoveCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -29,7 +29,6 @@ impl PerformCrud for EditCommunity {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CommunityResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &EditCommunity = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -20,7 +20,6 @@ impl PerformCrud for CreateCustomEmoji {
#[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CustomEmojiResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreateCustomEmoji = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -18,7 +18,6 @@ impl PerformCrud for DeleteCustomEmoji {
context: &Data<LemmyContext>,
) -> Result<DeleteCustomEmojiResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &DeleteCustomEmoji = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -20,7 +20,6 @@ impl PerformCrud for EditCustomEmoji {
#[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<CustomEmojiResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &EditCustomEmoji = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -45,7 +45,6 @@ impl PerformCrud for CreatePost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreatePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -19,7 +19,6 @@ impl PerformCrud for DeletePost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &DeletePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -26,7 +26,6 @@ impl PerformCrud for GetPost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetPostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &GetPost = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -22,7 +22,6 @@ impl PerformCrud for RemovePost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &RemovePost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -31,7 +31,6 @@ impl PerformCrud for EditPost {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<PostResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &EditPost = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -36,7 +36,6 @@ impl PerformCrud for CreatePrivateMessage {
context: &Data<LemmyContext>,
) -> Result<PrivateMessageResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreatePrivateMessage = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -22,7 +22,6 @@ impl PerformCrud for DeletePrivateMessage {
context: &Data<LemmyContext>,
) -> Result<PrivateMessageResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &DeletePrivateMessage = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -18,7 +18,6 @@ impl PerformCrud for GetPrivateMessages {
context: &Data<LemmyContext>,
) -> Result<PrivateMessagesResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &GetPrivateMessages = self;
let local_user_view = local_user_view_from_jwt(data.auth.as_ref(), context).await?;
let person_id = local_user_view.person.id;

View File

@ -29,7 +29,6 @@ impl PerformCrud for EditPrivateMessage {
context: &Data<LemmyContext>,
) -> Result<PrivateMessageResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &EditPrivateMessage = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let local_site = LocalSite::read(&mut conn).await?;

View File

@ -48,7 +48,6 @@ impl PerformCrud for CreateSite {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<SiteResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &CreateSite = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;

View File

@ -31,7 +31,6 @@ impl PerformCrud for GetSite {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetSiteResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &GetSite = self;
let site_view = SiteView::read_local(&mut conn).await?;

View File

@ -45,7 +45,6 @@ impl PerformCrud for EditSite {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<SiteResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &EditSite = self;
let local_user_view = local_user_view_from_jwt(&data.auth, context).await?;
let site_view = SiteView::read_local(&mut conn).await?;

View File

@ -44,7 +44,6 @@ impl PerformCrud for Register {
#[tracing::instrument(skip(self, context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<LoginResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &Register = self;
let site_view = SiteView::read_local(&mut conn).await?;

View File

@ -152,7 +152,6 @@ impl ActivityHandler for BlockUser {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
let expires = self.expires.map(|u| u.naive_local());
let mod_person = self.actor.dereference(context).await?;

View File

@ -139,7 +139,6 @@ impl SendActivity for BanPerson {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let person = Person::read(&mut conn, request.person_id).await?;
let site = SiteOrCommunity::Site(SiteView::read_local(&mut conn).await?.site.into());
@ -184,7 +183,6 @@ impl SendActivity for BanFromCommunity {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community: ApubCommunity = Community::read(&mut conn, request.community_id)
.await?

View File

@ -39,7 +39,6 @@ impl UndoBlockUser {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let block = BlockUser::new(target, user, mod_, None, reason, None, context).await?;
let audience = if let SiteOrCommunity::Community(c) = target {
Some(c.id().into())
@ -99,7 +98,6 @@ impl ActivityHandler for UndoBlockUser {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
let expires = self.object.expires.map(|u| u.naive_local());
let mod_person = self.actor.dereference(context).await?;

View File

@ -118,7 +118,6 @@ impl ActivityHandler for CollectionAdd {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
let (community, collection_type) =
Community::get_by_collection_url(&mut conn, &self.target.into()).await?;
@ -176,7 +175,6 @@ impl SendActivity for AddModToCommunity {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community: ApubCommunity = Community::read(&mut conn, request.community_id)
.await?
@ -212,7 +210,6 @@ impl SendActivity for FeaturePost {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community = Community::read(&mut conn, response.post_view.community.id)
.await?

View File

@ -111,7 +111,6 @@ impl ActivityHandler for CollectionRemove {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
let (community, collection_type) =
Community::get_by_collection_url(&mut conn, &self.target.into()).await?;

View File

@ -59,7 +59,6 @@ impl ActivityHandler for LockPage {
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
let mut conn = context.conn().await?;
let form = PostUpdateForm::builder().locked(Some(true)).build();
let post = self.object.dereference(context).await?;
Post::update(&mut conn, post.id, &form).await?;
@ -97,7 +96,6 @@ impl ActivityHandler for UndoLockPage {
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
let form = PostUpdateForm::builder().locked(Some(false)).build();
let post = self.object.object.dereference(context).await?;
@ -116,7 +114,6 @@ impl SendActivity for LockPost {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let id = generate_activity_id(
LockType::Lock,

View File

@ -38,8 +38,7 @@ pub(crate) async fn send_activity_in_community(
is_mod_action: bool,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
// send to any users which are mentioned or affected directly
let mut conn = context.conn().await?; // send to any users which are mentioned or affected directly
let mut inboxes = extra_inboxes;
// send to user followers

View File

@ -123,7 +123,6 @@ impl ActivityHandler for Report {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, true, context).await?;
let actor = self.actor.dereference(context).await?;
match self.object.dereference(context).await? {

View File

@ -36,7 +36,6 @@ impl SendActivity for EditCommunity {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community = Community::read(&mut conn, request.community_id).await?;
UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await
@ -95,7 +94,6 @@ impl ActivityHandler for UpdateCommunity {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
let community = self.community(context).await?;
@ -116,7 +114,6 @@ impl SendActivity for HideCommunity {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community = Community::read(&mut conn, request.community_id).await?;
UpdateCommunity::send(community.into(), &local_user_view.person.into(), context).await

View File

@ -89,8 +89,7 @@ impl CreateOrUpdateNote {
kind: CreateOrUpdateType,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
// TODO: might be helpful to add a comment method to retrieve community directly
let mut conn = context.conn().await?; // TODO: might be helpful to add a comment method to retrieve community directly
let post_id = comment.post_id;
let post = Post::read(&mut conn, post_id).await?;
let community_id = post.community_id;
@ -169,7 +168,6 @@ impl ActivityHandler for CreateOrUpdateNote {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
// Need to do this check here instead of Note::from_json because we need the person who
// send the activity, not the comment author.

View File

@ -108,7 +108,6 @@ impl CreateOrUpdatePage {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let post = ApubPost(post.clone());
let community_id = post.community_id;
let person: ApubPerson = Person::read(&mut conn, person_id).await?.into();
@ -181,7 +180,6 @@ impl ActivityHandler for CreateOrUpdatePage {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
let post = ApubPost::from_json(self.object, context).await?;

View File

@ -71,7 +71,6 @@ impl CreateOrUpdateChatMessage {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let recipient_id = private_message.recipient_id;
let sender: ApubPerson = Person::read(&mut conn, sender_id).await?.into();
let recipient: ApubPerson = Person::read(&mut conn, recipient_id).await?.into();

View File

@ -106,7 +106,6 @@ pub(in crate::activities) async fn receive_remove_action(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
match DeletableObjects::read_from_db(object, context).await? {
DeletableObjects::Community(community) => {
if community.local {

View File

@ -29,7 +29,6 @@ impl SendActivity for DeleteAccount {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let actor: ApubPerson = local_user_view.person.into();
delete_user_account(actor.id, &mut conn, context.settings(), context.client()).await?;
@ -77,7 +76,6 @@ impl ActivityHandler for DeleteUser {
async fn receive(self, context: &Data<Self::DataType>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, false, context).await?;
let actor = self.actor.dereference(context).await?;
delete_user_account(actor.id, &mut conn, context.settings(), context.client()).await?;

View File

@ -64,7 +64,6 @@ impl SendActivity for DeletePost {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community = Community::read(&mut conn, response.post_view.community.id).await?;
let deletable = DeletableObjects::Post(response.post_view.post.clone().into());
@ -90,7 +89,6 @@ impl SendActivity for RemovePost {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community = Community::read(&mut conn, response.post_view.community.id).await?;
let deletable = DeletableObjects::Post(response.post_view.post.clone().into());
@ -116,7 +114,6 @@ impl SendActivity for DeleteComment {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let community_id = response.comment_view.community.id;
let community = Community::read(&mut conn, community_id).await?;
let person = Person::read(&mut conn, response.comment_view.creator.id).await?;
@ -136,7 +133,6 @@ impl SendActivity for RemoveComment {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let comment = Comment::read(&mut conn, request.comment_id).await?;
let community = Community::read(&mut conn, response.comment_view.community.id).await?;
@ -183,7 +179,6 @@ impl SendActivity for DeleteCommunity {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community = Community::read(&mut conn, request.community_id).await?;
let deletable = DeletableObjects::Community(community.clone().into());
@ -209,7 +204,6 @@ impl SendActivity for RemoveCommunity {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community = Community::read(&mut conn, request.community_id).await?;
let deletable = DeletableObjects::Community(community.clone().into());
@ -264,7 +258,6 @@ async fn send_apub_delete_private_message(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let recipient_id = pm.recipient_id;
let recipient: ApubPerson = Person::read(&mut conn, recipient_id).await?.into();
@ -393,7 +386,6 @@ async fn receive_delete_action(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
match DeletableObjects::read_from_db(object, context).await? {
DeletableObjects::Community(community) => {
if community.local {

View File

@ -98,7 +98,6 @@ impl UndoDelete {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
match DeletableObjects::read_from_db(object, context).await? {
DeletableObjects::Community(community) => {
if community.local {

View File

@ -61,7 +61,6 @@ impl ActivityHandler for AcceptFollow {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, true, context).await?;
let community = self.actor.dereference(context).await?;
let person = self.object.actor.dereference(context).await?;

View File

@ -61,7 +61,6 @@ impl Follow {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let community_follower_form = CommunityFollowerForm {
community_id: community.id,
person_id: actor.id,
@ -106,7 +105,6 @@ impl ActivityHandler for Follow {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, true, context).await?;
let actor = self.actor.dereference(context).await?;
let object = self.object.dereference(context).await?;
@ -143,7 +141,6 @@ impl SendActivity for BlockCommunity {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let community = Community::read(&mut conn, request.community_id).await?;
UndoFollow::send(&local_user_view.person.into(), &community.into(), context).await

View File

@ -26,7 +26,6 @@ impl SendActivity for FollowCommunity {
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
let person = local_user_view.person.clone().into();
let community: ApubCommunity = Community::read(&mut conn, request.community_id)

View File

@ -72,7 +72,6 @@ impl ActivityHandler for UndoFollow {
#[tracing::instrument(skip_all)]
async fn receive(self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
insert_activity(&self.id, &self, false, true, context).await?;
let person = self.actor.dereference(context).await?;
let object = self.object.object.dereference(context).await?;

View File

@ -54,7 +54,6 @@ pub(crate) async fn verify_person_in_community(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let person = person_id.dereference(context).await?;
if person.banned {
return Err(LemmyError::from_message("Person is banned from site"));
@ -84,7 +83,6 @@ pub(crate) async fn verify_mod_action(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let mod_ = mod_id.dereference(context).await?;
let is_mod_or_admin = CommunityView::is_mod_or_admin(&mut conn, mod_.id, community_id).await?;

View File

@ -84,7 +84,6 @@ async fn send_activity(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let community = Community::read(&mut conn, community_id).await?.into();
let local_user_view = local_user_view_from_jwt(jwt, context).await?;
let actor = Person::read(&mut conn, local_user_view.person.id)
@ -113,7 +112,6 @@ async fn vote_comment(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let comment_id = comment.id;
let like_form = CommentLikeForm {
comment_id,
@ -135,7 +133,6 @@ async fn vote_post(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let post_id = post.id;
let like_form = PostLikeForm {
post_id: post.id,
@ -155,7 +152,6 @@ async fn undo_vote_comment(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let comment_id = comment.id;
let person_id = actor.id;
CommentLike::remove(&mut conn, person_id, comment_id).await?;
@ -169,7 +165,6 @@ async fn undo_vote_post(
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let mut conn = context.conn().await?;
let post_id = post.id;
let person_id = actor.id;
PostLike::remove(&mut conn, person_id, post_id).await?;

View File

@ -23,7 +23,6 @@ impl PerformApub for GetComments {
#[tracing::instrument(skip(context))]
async fn perform(&self, context: &Data<LemmyContext>) -> Result<GetCommentsResponse, LemmyError> {
let mut conn = context.conn().await?;
let data: &GetComments = self;
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
let local_site = LocalSite::read(&mut conn).await?;
@ -57,7 +56,6 @@ impl PerformApub for GetComments {
let post_id = data.post_id;
let local_user = local_user_view.map(|l| l.local_user);
let mut conn = context.conn().await?;
let comments = CommentQuery::builder()
.conn(&mut conn)
.listing_type(Some(listing_type))

Some files were not shown because too many files have changed in this diff Show More