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

Add google.sent_time extra to C2DM receive intent, fixes Telegram notifications #2344

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public final class GcmConstants {
public static final String EXTRA_SENDER_LEGACY = "legacy.sender";
public static final String EXTRA_SEND_TO = "google.to";
public static final String EXTRA_SEND_FROM = "google.from";
public static final String EXTRA_SENT_TIME = "google.sent_time";
public static final String EXTRA_SIGNATURE = "sig";
public static final String EXTRA_SUBSCIPTION = "subscription";
public static final String EXTRA_SUBTYPE = "subtype";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;

import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -548,6 +549,8 @@ private void handleAppMessage(DataMessageStanza msg) {
intent.setAction(ACTION_C2DM_RECEIVE);
intent.putExtra(EXTRA_FROM, msg.from);
intent.putExtra(EXTRA_MESSAGE_ID, msg.id);
if (msg.sent != null && msg.sent != 0) intent.putExtra(EXTRA_SENT_TIME, msg.sent);
if (msg.ttl != null && msg.ttl != 0) intent.putExtra(EXTRA_TTL, msg.ttl);
if (msg.persistent_id != null) intent.putExtra(EXTRA_MESSAGE_ID, msg.persistent_id);
if (msg.token != null) intent.putExtra(EXTRA_COLLAPSE_KEY, msg.token);
if (msg.raw_data != null) {
Expand All @@ -560,6 +563,10 @@ private void handleAppMessage(DataMessageStanza msg) {
intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
}
for (AppData appData : msg.app_data) {
if (appData.key == null) continue;
String key = appData.key.toLowerCase(Locale.US);
// Some keys are exclusively set by the client and not the app.
if (key.equals(EXTRA_FROM) || (key.startsWith("google.") && !key.startsWith("google.c."))) continue;
intent.putExtra(appData.key, appData.value_);
}

Expand Down