mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
feat: message previews
- Remove partial downloads (remove creation of the stub messages) (#7373) - Remove "Download maximum available until" and remove stock string `DC_STR_DOWNLOAD_AVAILABILITY` (#7369) - Send pre-message on messages with large attachments (#7410) - Pre messages can now get read receipts (#7433) Co-authored-by: Hocuri <hocuri@gmx.de>
This commit is contained in:
@@ -4,7 +4,6 @@ use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use humansize::{BINARY, format_size};
|
||||
use strum::EnumProperty as EnumPropertyTrait;
|
||||
use strum_macros::EnumProperty;
|
||||
use tokio::sync::RwLock;
|
||||
@@ -17,7 +16,6 @@ use crate::contact::{Contact, ContactId};
|
||||
use crate::context::Context;
|
||||
use crate::message::{Message, Viewtype};
|
||||
use crate::param::Param;
|
||||
use crate::tools::timestamp_to_str;
|
||||
|
||||
/// Storage for string translations.
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -167,12 +165,6 @@ pub enum StockMessage {
|
||||
))]
|
||||
QuotaExceedingMsgBody = 98,
|
||||
|
||||
#[strum(props(fallback = "%1$s message"))]
|
||||
PartialDownloadMsgBody = 99,
|
||||
|
||||
#[strum(props(fallback = "Download maximum available until %1$s"))]
|
||||
DownloadAvailability = 100,
|
||||
|
||||
#[strum(props(fallback = "Multi Device Synchronization"))]
|
||||
SyncMsgSubject = 101,
|
||||
|
||||
@@ -423,6 +415,9 @@ https://delta.chat/donate"))]
|
||||
|
||||
#[strum(props(fallback = "Messages in this chat use classic email and are not encrypted."))]
|
||||
ChatUnencryptedExplanation = 230,
|
||||
|
||||
#[strum(props(fallback = "Contact"))]
|
||||
Contact = 231,
|
||||
}
|
||||
|
||||
impl StockMessage {
|
||||
@@ -890,6 +885,11 @@ pub(crate) async fn sticker(context: &Context) -> String {
|
||||
translated(context, StockMessage::Sticker).await
|
||||
}
|
||||
|
||||
/// Stock string: `Contact`.
|
||||
pub(crate) async fn contact(context: &Context) -> String {
|
||||
translated(context, StockMessage::Contact).await
|
||||
}
|
||||
|
||||
/// Stock string: `Device messages`.
|
||||
pub(crate) async fn device_messages(context: &Context) -> String {
|
||||
translated(context, StockMessage::DeviceMessages).await
|
||||
@@ -1119,21 +1119,6 @@ pub(crate) async fn quota_exceeding(context: &Context, highest_usage: u64) -> St
|
||||
.replace("%%", "%")
|
||||
}
|
||||
|
||||
/// Stock string: `%1$s message` with placeholder replaced by human-readable size.
|
||||
pub(crate) async fn partial_download_msg_body(context: &Context, org_bytes: u32) -> String {
|
||||
let size = &format_size(org_bytes, BINARY);
|
||||
translated(context, StockMessage::PartialDownloadMsgBody)
|
||||
.await
|
||||
.replace1(size)
|
||||
}
|
||||
|
||||
/// Stock string: `Download maximum available until %1$s`.
|
||||
pub(crate) async fn download_availability(context: &Context, timestamp: i64) -> String {
|
||||
translated(context, StockMessage::DownloadAvailability)
|
||||
.await
|
||||
.replace1(×tamp_to_str(timestamp))
|
||||
}
|
||||
|
||||
/// Stock string: `Incoming Messages`.
|
||||
pub(crate) async fn incoming_messages(context: &Context) -> String {
|
||||
translated(context, StockMessage::IncomingMessages).await
|
||||
@@ -1262,6 +1247,24 @@ pub(crate) async fn chat_unencrypted_explanation(context: &Context) -> String {
|
||||
translated(context, StockMessage::ChatUnencryptedExplanation).await
|
||||
}
|
||||
|
||||
impl Viewtype {
|
||||
/// returns Localized name for message viewtype
|
||||
pub async fn to_locale_string(&self, context: &Context) -> String {
|
||||
match self {
|
||||
Viewtype::Image => image(context).await,
|
||||
Viewtype::Gif => gif(context).await,
|
||||
Viewtype::Sticker => sticker(context).await,
|
||||
Viewtype::Audio => audio(context).await,
|
||||
Viewtype::Voice => voice_message(context).await,
|
||||
Viewtype::Video => video(context).await,
|
||||
Viewtype::File => file(context).await,
|
||||
Viewtype::Webxdc => "Mini App".to_owned(),
|
||||
Viewtype::Vcard => contact(context).await,
|
||||
Viewtype::Unknown | Viewtype::Text | Viewtype::Call => self.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Context {
|
||||
/// Set the stock string for the [StockMessage].
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user