refactor(timeline): homogeneize naming of replied_to vs in_reply_to

This commit is contained in:
Benjamin Bouvier
2025-07-21 18:09:44 +02:00
parent e2148e46bc
commit 6e9fc70d13
3 changed files with 11 additions and 11 deletions

View File

@@ -110,7 +110,7 @@ impl Timeline {
let mime_str = mime_type.as_ref().ok_or(RoomError::InvalidAttachmentMimeType)?;
let mime_type =
mime_str.parse::<Mime>().map_err(|_| RoomError::InvalidAttachmentMimeType)?;
let replied_to_event_id = params
let in_reply_to_event_id = params
.in_reply_to
.map(EventId::parse)
.transpose()
@@ -127,7 +127,7 @@ impl Timeline {
caption: params.caption,
formatted_caption,
mentions: params.mentions.map(Into::into),
replied_to: replied_to_event_id,
in_reply_to: in_reply_to_event_id,
..Default::default()
};

View File

@@ -73,7 +73,7 @@ impl<'a> IntoFuture for SendAttachment<'a> {
let fut = async move {
let (data, filename) = source.try_into_bytes_and_filename()?;
let reply = timeline.infer_reply(config.replied_to).await;
let reply = timeline.infer_reply(config.in_reply_to).await;
let sdk_config = matrix_sdk::attachment::AttachmentConfig {
txn_id: config.txn_id,
info: config.info,

View File

@@ -172,7 +172,7 @@ pub enum DateDividerMode {
/// Configuration for sending an attachment.
///
/// Like [`matrix_sdk::attachment::AttachmentConfig`], but instead of the
/// `reply` field, there's only a `replied_to` event id; it's the timeline
/// `reply` field, there's only a `in_reply_to` event id; it's the timeline
/// deciding to fill the rest of the reply parameters.
#[derive(Debug, Default)]
pub struct AttachmentConfig {
@@ -182,7 +182,7 @@ pub struct AttachmentConfig {
pub caption: Option<String>,
pub formatted_caption: Option<FormattedBody>,
pub mentions: Option<Mentions>,
pub replied_to: Option<OwnedEventId>,
pub in_reply_to: Option<OwnedEventId>,
}
impl Timeline {
@@ -346,10 +346,10 @@ impl Timeline {
pub async fn send_reply(
&self,
content: RoomMessageEventContentWithoutRelation,
replied_to: OwnedEventId,
in_reply_to: OwnedEventId,
) -> Result<(), Error> {
let reply = self
.infer_reply(Some(replied_to))
.infer_reply(Some(in_reply_to))
.await
.expect("the reply will always be set because we provided a replied-to event id");
let content = self.room().make_reply_event(content, reply).await?;
@@ -357,19 +357,19 @@ impl Timeline {
Ok(())
}
/// Given a message or media to send, and an optional `replied_to` event,
/// Given a message or media to send, and an optional `in_reply_to` event,
/// automatically fills the [`Reply`] information based on the current
/// timeline focus.
pub(crate) async fn infer_reply(&self, replied_to: Option<OwnedEventId>) -> Option<Reply> {
pub(crate) async fn infer_reply(&self, in_reply_to: Option<OwnedEventId>) -> Option<Reply> {
// If there's a replied-to event id, the reply is pretty straightforward, and we
// should only infer the `EnforceThread` based on the current focus.
if let Some(replied_to) = replied_to {
if let Some(in_reply_to) = in_reply_to {
let enforce_thread = if self.controller.is_threaded() {
EnforceThread::Threaded(ReplyWithinThread::Yes)
} else {
EnforceThread::MaybeThreaded
};
return Some(Reply { event_id: replied_to, enforce_thread });
return Some(Reply { event_id: in_reply_to, enforce_thread });
}
let thread_root = self.controller.thread_root()?;