Skip to content

Commit 6658e28

Browse files
committed
allow mozilla sunup as push server. it needs to be allowed in the settings
1 parent 96d99dd commit 6658e28

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperRelay.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@
3737
import static com.zoffcc.applications.trifa.HelperGroup.is_group_we_left;
3838
import static com.zoffcc.applications.trifa.HelperGroup.tox_group_by_groupid__wrapper;
3939
import static com.zoffcc.applications.trifa.MainActivity.PREF__allow_push_server_ntfy;
40+
import static com.zoffcc.applications.trifa.MainActivity.PREF__allow_push_server_sunup;
4041
import static com.zoffcc.applications.trifa.MainActivity.tox_conference_invite;
4142
import static com.zoffcc.applications.trifa.MainActivity.tox_friend_send_lossless_packet;
4243
import static com.zoffcc.applications.trifa.MainActivity.tox_group_invite_friend;
4344
import static com.zoffcc.applications.trifa.TRIFAGlobals.CONTROL_PROXY_MESSAGE_TYPE.CONTROL_PROXY_MESSAGE_TYPE_FRIEND_PUBKEY_FOR_PROXY;
4445
import static com.zoffcc.applications.trifa.TRIFAGlobals.CONTROL_PROXY_MESSAGE_TYPE.CONTROL_PROXY_MESSAGE_TYPE_GROUP_ID_FOR_PROXY;
4546
import static com.zoffcc.applications.trifa.TRIFAGlobals.CONTROL_PROXY_MESSAGE_TYPE.CONTROL_PROXY_MESSAGE_TYPE_NOTIFICATION_TOKEN;
4647
import static com.zoffcc.applications.trifa.TRIFAGlobals.CONTROL_PROXY_MESSAGE_TYPE.CONTROL_PROXY_MESSAGE_TYPE_PROXY_PUBKEY_FOR_FRIEND;
48+
import static com.zoffcc.applications.trifa.TRIFAGlobals.MAX_PUSH_URL_LENGTH;
4749
import static com.zoffcc.applications.trifa.TRIFAGlobals.NOTIFICATION_FCM_PUSH_URL_PREFIX;
4850
import static com.zoffcc.applications.trifa.TRIFAGlobals.NOTIFICATION_FCM_PUSH_URL_PREFIX_OLD;
4951
import static com.zoffcc.applications.trifa.TRIFAGlobals.NOTIFICATION_NTFY_PUSH_URL_PREFIX;
52+
import static com.zoffcc.applications.trifa.TRIFAGlobals.NOTIFICATION_SUNUP_PUSH_URL_PREFIX;
5053
import static com.zoffcc.applications.trifa.TRIFAGlobals.NOTIFICATION_TOKEN_DB_KEY;
5154
import static com.zoffcc.applications.trifa.TRIFAGlobals.NOTIFICATION_UP_PUSH_URL_PREFIX;
5255
import static com.zoffcc.applications.trifa.ToxVars.TOX_GROUP_CHAT_ID_SIZE;
@@ -371,7 +374,7 @@ static String push_token_to_push_url(final String push_token)
371374
notification_push_url = NOTIFICATION_FCM_PUSH_URL_PREFIX + push_token;
372375
}
373376

374-
if (notification_push_url.length() < 1000)
377+
if (notification_push_url.length() < MAX_PUSH_URL_LENGTH)
375378
{
376379
return notification_push_url;
377380
}
@@ -543,6 +546,18 @@ static boolean is_valid_pushurl_for_friend_with_whitelist(String push_url)
543546
}
544547
}
545548

549+
// whitelist mozilla sunup server
550+
if (PREF__allow_push_server_sunup)
551+
{
552+
if (push_url.length() > NOTIFICATION_SUNUP_PUSH_URL_PREFIX.length())
553+
{
554+
if (push_url.startsWith(NOTIFICATION_SUNUP_PUSH_URL_PREFIX))
555+
{
556+
return true;
557+
}
558+
}
559+
}
560+
546561
// anything else is not allowed at this time!
547562
return false;
548563
}

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ public class MainActivity extends AppCompatActivity
539539
static boolean PREF__show_friendnumber_on_friendlist = false;
540540
static int PREF__dark_mode_pref = 0;
541541
static boolean PREF__allow_push_server_ntfy = false;
542+
static boolean PREF__allow_push_server_sunup = false;
542543
static boolean PREF__messageview_paging = true;
543544
static int PREF__message_paging_num_msgs_per_page = 50;
544545
static int PREF__ngc_video_bitrate = LOWER_NGC_VIDEO_BITRATE; // ~600 kbits/s -> ~60 kbytes/s
@@ -1295,6 +1296,16 @@ public void onNotYetInstalled()
12951296
PREF__allow_push_server_ntfy = false;
12961297
}
12971298

1299+
try
1300+
{
1301+
PREF__allow_push_server_sunup = settings.getBoolean("allow_push_server_sunup", false);
1302+
}
1303+
catch (Exception e)
1304+
{
1305+
e.printStackTrace();
1306+
PREF__allow_push_server_sunup = false;
1307+
}
1308+
12981309
try
12991310
{
13001311
PREF__use_push_service = settings.getBoolean("use_push_service", true);
@@ -3930,6 +3941,16 @@ else if (PREF__higher_audio_quality == 1)
39303941
PREF__allow_push_server_ntfy = false;
39313942
}
39323943

3944+
try
3945+
{
3946+
PREF__allow_push_server_sunup = settings.getBoolean("allow_push_server_sunup", false);
3947+
}
3948+
catch (Exception e)
3949+
{
3950+
e.printStackTrace();
3951+
PREF__allow_push_server_sunup = false;
3952+
}
3953+
39333954
try
39343955
{
39353956
PREF__use_push_service = settings.getBoolean("use_push_service", true);

android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/TRIFAGlobals.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ public class TRIFAGlobals
4646
static int global_tox_self_status = ToxVars.TOX_USER_STATUS.TOX_USER_STATUS_NONE.value;
4747

4848
static String global_notification_token = null;
49+
final static int MAX_PUSH_URL_LENGTH = 3000;
4950
final static String NOTIFICATION_TOKEN_DB_KEY = "NotificationToken";
5051
final static String NOTIFICATION_TOKEN_DB_KEY_NEED_ACK = "NotificationTokenNeedACK";
5152
final static String NOTIFICATION_FCM_PUSH_URL_PREFIX = "https://tox.zoff.xyz/toxfcm/fcm.php?id=";
5253
final static String NOTIFICATION_FCM_PUSH_URL_PREFIX_OLD = "https://toxcon2020.zoff.cc/toxfcm/fcm.php?id=";
5354
final static String NOTIFICATION_UP_PUSH_URL_PREFIX = "https://gotify1.unifiedpush.org/UP?token=";
5455
final static String NOTIFICATION_NTFY_PUSH_URL_PREFIX = "https://ntfy.sh/";
56+
final static String NOTIFICATION_SUNUP_PUSH_URL_PREFIX = "https://updates.push.services.mozilla.com/wpush/";
5557

5658
final static String TOX_PUSH_MSG_APP_WEBDOWNLOAD = "https://github.com/zoff99/tox_push_msg_app/releases/latest/download/play.pushmsg.apk";
5759
final static String TOX_PUSH_MSG_APP_PLAYSTORE = "https://play.google.com/store/apps/details?id=com.zoffcc.applications.pushmsg";

android-refimpl-app/app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@
195195
<string name="pref_title_allow_push_server_ntfy">Allow ntfy.sh Server</string>
196196
<string name="pref_description_allow_push_server_ntfy">WARNING: Allow ntfy.sh server for push notifications, this may leak your metadata of timestamps when you receive push notifications, if a friend subscribes with your push token. ntfy.sh has NO passwords and NO authentication. you have been warned.</string>
197197

198+
<string name="pref_title_allow_push_server_sunup">Allow Moziall sunup Server</string>
199+
<string name="pref_description_allow_push_server_sunup">WARNING: Allow Mozilla sunup server for push notifications, this may leak your metadata of timestamps when you receive push notifications, if a friend subscribes with your push token. Mozilla sunup has NO passwords and NO authentication. you have been warned.</string>
200+
198201
<string name="pref_title_download_push_msg_app">Download Push Message App</string>
199202

200203
<string name="pref_title_custom_bootstrap_nodes">Use Custom Bootstrap nodes</string>

android-refimpl-app/app/src/main/res/xml/pref_general.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
android:summary="@string/pref_description_allow_push_server_ntfy"
3333
android:title="@string/pref_title_allow_push_server_ntfy" />
3434

35+
<SwitchPreference
36+
android:defaultValue="false"
37+
android:key="allow_push_server_sunup"
38+
android:summary="@string/pref_description_allow_push_server_sunup"
39+
android:title="@string/pref_title_allow_push_server_sunup" />
40+
3541
<SwitchPreference
3642
android:defaultValue="false"
3743
android:key="compact_friendlist"

0 commit comments

Comments
 (0)