mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-29 15:51:20 +00:00
Add blank lines under each line with conn =
This commit is contained in:
parent
d2c6263ea1
commit
773a6d3beb
137 changed files with 206 additions and 6 deletions
|
@ -19,6 +19,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ 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?;
|
||||
|
|
|
@ -20,6 +20,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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)
|
||||
|
|
|
@ -28,6 +28,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ 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();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ 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
|
||||
|
|
|
@ -18,6 +18,7 @@ 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 {
|
||||
|
|
|
@ -14,6 +14,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ 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?;
|
||||
|
|
|
@ -28,6 +28,7 @@ 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)
|
||||
|
|
|
@ -25,6 +25,7 @@ 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)
|
||||
|
|
|
@ -19,6 +19,7 @@ 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;
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ impl Perform for PasswordReset {
|
|||
context: &Data<LemmyContext>,
|
||||
) -> Result<PasswordResetResponse, LemmyError> {
|
||||
let mut conn = context.conn().await?;
|
||||
|
||||
let data: &PasswordReset = self;
|
||||
|
||||
// Fetch that email
|
||||
|
|
|
@ -34,6 +34,7 @@ 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?;
|
||||
|
|
|
@ -19,6 +19,7 @@ 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
|
||||
|
|
|
@ -29,6 +29,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ 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?;
|
||||
|
|
|
@ -27,6 +27,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ 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?;
|
||||
|
|
|
@ -30,6 +30,7 @@ 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)
|
||||
|
|
|
@ -17,6 +17,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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)
|
||||
|
|
|
@ -16,6 +16,7 @@ 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)?;
|
||||
|
|
|
@ -15,6 +15,7 @@ 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?;
|
||||
|
|
|
@ -26,6 +26,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ 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;
|
||||
|
|
|
@ -21,6 +21,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ 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?;
|
||||
|
@ -29,6 +30,7 @@ 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)
|
||||
|
|
|
@ -15,6 +15,7 @@ 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?;
|
||||
|
|
|
@ -139,6 +139,7 @@ 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;
|
||||
|
|
|
@ -42,6 +42,7 @@ 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?;
|
||||
|
|
|
@ -23,6 +23,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ 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?;
|
||||
|
|
|
@ -24,6 +24,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ 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?;
|
||||
|
|
|
@ -47,6 +47,7 @@ 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?;
|
||||
|
|
|
@ -20,6 +20,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ 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?;
|
||||
|
@ -33,6 +34,7 @@ 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)
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ 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?;
|
||||
|
|
|
@ -20,6 +20,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ 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?;
|
||||
|
|
|
@ -19,6 +19,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ 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?;
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ 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?;
|
||||
|
|
|
@ -36,6 +36,7 @@ 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?;
|
||||
|
|
|
@ -22,6 +22,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ 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;
|
||||
|
|
|
@ -29,6 +29,7 @@ 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?;
|
||||
|
|
|
@ -48,6 +48,7 @@ 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?;
|
||||
|
|
|
@ -31,6 +31,7 @@ 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?;
|
||||
|
|
|
@ -45,6 +45,7 @@ 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?;
|
||||
|
|
|
@ -44,6 +44,7 @@ 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?;
|
||||
|
|
|
@ -152,6 +152,7 @@ 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?;
|
||||
|
|
|
@ -139,6 +139,7 @@ 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());
|
||||
|
@ -183,6 +184,7 @@ 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?
|
||||
|
|
|
@ -39,6 +39,7 @@ 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())
|
||||
|
@ -98,6 +99,7 @@ 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?;
|
||||
|
|
|
@ -118,6 +118,7 @@ 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?;
|
||||
|
@ -175,6 +176,7 @@ 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?
|
||||
|
@ -210,6 +212,7 @@ 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?
|
||||
|
|
|
@ -111,6 +111,7 @@ 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?;
|
||||
|
|
|
@ -59,6 +59,7 @@ 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?;
|
||||
|
@ -96,6 +97,7 @@ 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?;
|
||||
|
@ -114,6 +116,7 @@ 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,
|
||||
|
|
|
@ -38,7 +38,8 @@ 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
|
||||
|
|
|
@ -123,6 +123,7 @@ 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? {
|
||||
|
|
|
@ -36,6 +36,7 @@ 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
|
||||
|
@ -94,6 +95,7 @@ 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?;
|
||||
|
||||
|
@ -114,6 +116,7 @@ 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
|
||||
|
|
|
@ -89,7 +89,8 @@ 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;
|
||||
|
@ -168,6 +169,7 @@ 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.
|
||||
|
|
|
@ -108,6 +108,7 @@ 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();
|
||||
|
@ -180,6 +181,7 @@ 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?;
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ 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();
|
||||
|
|
|
@ -106,6 +106,7 @@ 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 {
|
||||
|
|
|
@ -29,6 +29,7 @@ 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?;
|
||||
|
@ -76,6 +77,7 @@ 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?;
|
||||
|
|
|
@ -64,6 +64,7 @@ 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());
|
||||
|
@ -89,6 +90,7 @@ 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());
|
||||
|
@ -114,6 +116,7 @@ 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?;
|
||||
|
@ -133,6 +136,7 @@ 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?;
|
||||
|
@ -179,6 +183,7 @@ 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());
|
||||
|
@ -204,6 +209,7 @@ 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());
|
||||
|
@ -258,6 +264,7 @@ 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();
|
||||
|
||||
|
@ -386,6 +393,7 @@ 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 {
|
||||
|
|
|
@ -98,6 +98,7 @@ 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 {
|
||||
|
|
|
@ -61,6 +61,7 @@ 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?;
|
||||
|
|
|
@ -61,6 +61,7 @@ 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,
|
||||
|
@ -105,6 +106,7 @@ 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?;
|
||||
|
@ -141,6 +143,7 @@ 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
|
||||
|
|
|
@ -26,6 +26,7 @@ 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)
|
||||
|
|
|
@ -72,6 +72,7 @@ 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?;
|
||||
|
|
|
@ -54,6 +54,7 @@ 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"));
|
||||
|
@ -83,6 +84,7 @@ 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?;
|
||||
|
|
|
@ -84,6 +84,7 @@ 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)
|
||||
|
@ -112,6 +113,7 @@ 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,
|
||||
|
@ -133,6 +135,7 @@ 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,
|
||||
|
@ -152,6 +155,7 @@ 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?;
|
||||
|
@ -165,6 +169,7 @@ 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?;
|
||||
|
|
|
@ -23,6 +23,7 @@ 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?;
|
||||
|
@ -56,6 +57,7 @@ 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
Loading…
Reference in a new issue