push 2 for replied-to messages *am i cooked or am i cooking*
This commit is contained in:
@@ -18,6 +18,7 @@ CREATE TYPE IF NOT EXISTS payphone.message_metadata (
|
||||
propagation_message_id BIGINT,
|
||||
propagation_channel_id BIGINT,
|
||||
replying_to_id BIGINT,
|
||||
message_replied_to_metadata FROZEN<payphone.message_metadata>,
|
||||
is_deleted BOOLEAN,
|
||||
is_edited BOOLEAN,
|
||||
is_censored BOOLEAN
|
||||
|
||||
@@ -12,10 +12,55 @@ pub struct MessageMetadata {
|
||||
pub propagation_message_id: Option<i64>,
|
||||
pub propagation_channel_id: Option<i64>,
|
||||
pub replying_to_id: Option<i64>,
|
||||
pub message_replied_to_metadata: Option<Box<MessageMetadata>>,
|
||||
pub is_deleted: Option<bool>,
|
||||
pub is_edited: Option<bool>,
|
||||
pub is_censored: Option<bool>,
|
||||
}
|
||||
|
||||
impl<'a> Object<'a> for MessageMetadata {
|
||||
type Row = (
|
||||
i64, i64, Option<String>, Option<String>, Option<String>, Option<String>, Option<Vec<String>>, Option<i64>, Option<i64>, Option<i64>, Option<i64>, Option<Box<MessageMetadata>>, Option<bool>, Option<bool>, Option<bool>
|
||||
);
|
||||
fn from_row(row: Self::Row) -> Self {
|
||||
Self {
|
||||
call_id: row.0,
|
||||
author_id: row.1,
|
||||
author_name: row.2,
|
||||
author_avatar_url: row.3,
|
||||
author_mask: row.4,
|
||||
content: row.5,
|
||||
attachments: row.6,
|
||||
sticker: row.7,
|
||||
propagation_message_id: row.8,
|
||||
propagation_channel_id: row.9,
|
||||
replying_to_id: row.10,
|
||||
message_replied_to_metadata: row.11,
|
||||
is_deleted: row.12,
|
||||
is_edited: row.13,
|
||||
is_censored: row.14,
|
||||
}
|
||||
}
|
||||
fn to_row(value: Self) -> Self::Row {
|
||||
(
|
||||
value.call_id,
|
||||
value.author_id,
|
||||
value.author_name,
|
||||
value.author_avatar_url,
|
||||
value.author_mask,
|
||||
value.content,
|
||||
value.attachments,
|
||||
value.sticker,
|
||||
value.propagation_message_id,
|
||||
value.propagation_channel_id,
|
||||
value.replying_to_id,
|
||||
value.message_replied_to_metadata,
|
||||
value.is_deleted,
|
||||
value.is_edited,
|
||||
value.is_censored,
|
||||
)
|
||||
}
|
||||
}
|
||||
use scylla::{
|
||||
client::session::Session,
|
||||
deserialize::row::DeserializeRow,
|
||||
|
||||
@@ -38,16 +38,25 @@ impl MessageCommand<State> for ReportMessageCommand {
|
||||
.map_err(|_| InteractionError::InteractionNotFound)?
|
||||
.ok_or(InteractionError::InteractionNotFound)?;
|
||||
|
||||
// If the message is a reply, fetch the replied-to message and denormalize its metadata
|
||||
let mut message_metadata = message.message_metadata.clone();
|
||||
if let Some(replying_to_id) = message_metadata.replying_to_id {
|
||||
if let Ok(Some(reply_msg)) = Message::get_by_id(call_id, replying_to_id as u64, db).await {
|
||||
message_metadata.message_replied_to_metadata = Some(Box::new(reply_msg.message_metadata));
|
||||
}
|
||||
}
|
||||
|
||||
// Build the report using the new UDT-based message metadata
|
||||
let report = Report {
|
||||
report_id: get_random_u64(),
|
||||
message: message.message_metadata.clone(),
|
||||
message: message_metadata,
|
||||
created_at: time::OffsetDateTime::now_utc(),
|
||||
reviewed_at: None,
|
||||
created_by_ids: vec![ctx.event.author_id().map(|id| id.get()).unwrap_or(0)],
|
||||
reviewed_by_id: None,
|
||||
resolution: None,
|
||||
};
|
||||
|
||||
|
||||
// Insert the report
|
||||
report.insert(db).await.map_err(|_| InteractionError::DeferringFailed)?;
|
||||
|
||||
Reference in New Issue
Block a user