Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing notification support for iOS build #2496

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ LIB_OUT_DIR = "debug"
TARGET_OS = "unknown"
DEV = true
RELEASE = false
# FIXME currently needed to fix building for ios
# see https://github.com/matrix-org/matrix-rust-sdk/issues/4416
CARGO_FEATURE_NO_NEON=1

[env.release]
RELEASE = true
Expand Down
63 changes: 49 additions & 14 deletions native/acter/src/api/uniffi_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,69 @@ impl NotificationItem {

let ApiNotificationItem {
title,
push_style,
target_url,
room_invite,
thread_id,
body,
noisy,
sender,
image,
inner,
..
} = value;

let target_url = inner.target_url();
let room_invite = inner.room_invite();
let push_style = inner.key();
let body = inner.body();

let mut msg_title = title;
let mut short_msg = None;

if let Some(invite) = room_invite {
short_msg = Some(invite);
} else if let Some(content) = body {
short_msg = Some(content.body());
let parent_title = if let Some(p) = inner.parent() {
let parent_title = p.title().unwrap_or("boost".to_owned());
let parent_emoji = p.emoji();
Some(format!("{parent_emoji} {parent_title}"))
} else {
None
};

let sender_name = sender
.display_name()
.clone()
.unwrap_or_else(|| sender.user_id());

if let Some(content) = body {
let msg = Some(content.body());
short_msg = Some(format!("${sender_name}: $msg"))
}

if push_style == "chat" {
if let Some(sender_name) = sender.display_name() {
// wrap the user display name before the message
short_msg = Some(format!("${sender_name}: $short_msg"));
match push_style.as_str() {
"invite" => {
if let Some(invite_id) = room_invite {
short_msg = Some(invite_id.to_string());
}
}
"comment" => {
if let Some(pt) = parent_title {
msg_title = format!("💬 Comment on {pt}");
} else {
msg_title = "💬 Comment".to_owned();
}
}
"reaction" => {
short_msg = Some(sender_name);
let reaction = inner.reaction_key().unwrap_or("❤️".to_owned());

if let Some(pt) = parent_title {
msg_title = format!("{reaction} to {pt}");
} else {
msg_title = reaction;
}
}
_ => {
// e.g. "chat" -> default is fine.
}
}

NotificationItem {
title,
title: msg_title,
body: short_msg,
push_style,
target_url,
Expand Down
Loading