mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-15 00:43:59 +00:00
Riley
35cbae61bc
* Respond directly with LemmyError Instrument Perform implementations for more precise traces Use ApiError to format JSON errors when messages are present Keep SpanTrace output in LemmyError Display impl * Hide SpanTrace debug output from LemmyError * Don't log when entering spans, only when leaving * Update actix-web * Update actix-rt * Add newline after error info in LemmyError Display impl * Propogate span information to blocking operations * Instrument apub functions * Use skip_all for more instrument attributes, don't skip 'self' in some api actions * Make message a static string * Send proper JSON over websocket * Add 'message' to LemmyError display if present * Use a quieter root span builder, don't pretty-print logs * Keep passwords and emails out of logs * Re-enable logging Login * Instrument feeds * Emit our own errors * Move error log after status code recording * Make Sensitive generic over the inner type * Remove line that logged secrets
55 lines
1.6 KiB
Rust
55 lines
1.6 KiB
Rust
use crate::PerformCrud;
|
|
use actix_web::web::Data;
|
|
use lemmy_api_common::{
|
|
blocking,
|
|
get_local_user_view_from_jwt,
|
|
person::{GetPrivateMessages, PrivateMessagesResponse},
|
|
};
|
|
use lemmy_db_schema::traits::DeleteableOrRemoveable;
|
|
use lemmy_db_views::private_message_view::PrivateMessageQueryBuilder;
|
|
use lemmy_utils::{ConnectionId, LemmyError};
|
|
use lemmy_websocket::LemmyContext;
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
impl PerformCrud for GetPrivateMessages {
|
|
type Response = PrivateMessagesResponse;
|
|
|
|
#[tracing::instrument(skip(self, context, _websocket_id))]
|
|
async fn perform(
|
|
&self,
|
|
context: &Data<LemmyContext>,
|
|
_websocket_id: Option<ConnectionId>,
|
|
) -> Result<PrivateMessagesResponse, LemmyError> {
|
|
let data: &GetPrivateMessages = self;
|
|
let local_user_view =
|
|
get_local_user_view_from_jwt(data.auth.as_ref(), context.pool(), context.secret()).await?;
|
|
let person_id = local_user_view.person.id;
|
|
|
|
let page = data.page;
|
|
let limit = data.limit;
|
|
let unread_only = data.unread_only;
|
|
let mut messages = blocking(context.pool(), move |conn| {
|
|
PrivateMessageQueryBuilder::create(conn, person_id)
|
|
.page(page)
|
|
.limit(limit)
|
|
.unread_only(unread_only)
|
|
.list()
|
|
})
|
|
.await??;
|
|
|
|
// Blank out deleted or removed info
|
|
for pmv in messages
|
|
.iter_mut()
|
|
.filter(|pmv| pmv.private_message.deleted)
|
|
{
|
|
pmv.private_message = pmv
|
|
.to_owned()
|
|
.private_message
|
|
.blank_out_deleted_or_removed_info();
|
|
}
|
|
|
|
Ok(PrivateMessagesResponse {
|
|
private_messages: messages,
|
|
})
|
|
}
|
|
}
|