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

2.25 fixes #8578

Merged
merged 2 commits into from
Feb 11, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,25 @@
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import androidx.core.app.Person;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;

import com.mattermost.helpers.*;
import com.mattermost.turbolog.TurboLog;
import com.wix.reactnativenotifications.core.NotificationIntentAdapter;
import com.wix.reactnativenotifications.core.notification.INotificationsApplication;
import com.wix.reactnativenotifications.core.notification.PushNotificationProps;

public class NotificationReplyBroadcastReceiver extends BroadcastReceiver {
private Context mContext;
private Bundle bundle;
private NotificationManager notificationManager;

private ReactApplicationContext getReactContext(Context context) {
if (context instanceof ReactApplication) {
ReactNativeHost host = ((ReactApplication) context).getReactNativeHost();
return (ReactApplicationContext) host.getReactInstanceManager().getCurrentReactContext();
}

return null;
}

@Override
public void onReceive(Context context, Intent intent) {
try {
Expand Down Expand Up @@ -80,7 +69,6 @@ protected void replyToMessage(final String serverUrl, final int notificationId,
WritableMap headers = Arguments.createMap();
headers.putString("Content-Type", "application/json");


WritableMap body = Arguments.createMap();
body.putString("channel_id", channelId);
body.putString("message", message.toString());
Expand All @@ -92,9 +80,19 @@ protected void replyToMessage(final String serverUrl, final int notificationId,

String postsEndpoint = "/api/v4/posts?set_online=false";
Network.post(serverUrl, postsEndpoint, options, new ResolvePromise() {
private boolean isSuccessful(int statusCode) {
return statusCode >= 200 && statusCode < 300;
}
@Override
public void resolve(@Nullable Object value) {
if (value != null) {
ReadableMap response = (ReadableMap)value;
ReadableMap data = response.getMap("data");
if (data != null && data.hasKey("status_code") && !isSuccessful(data.getInt("status_code"))) {
TurboLog.Companion.i("ReactNative", String.format("Reply FAILED exception %s", data.getString("message")));
onReplyFailed(notificationId);
return;
}
onReplySuccess(notificationId, message);
TurboLog.Companion.i("ReactNative", "Reply SUCCESS");
} else {
Expand All @@ -104,13 +102,13 @@ public void resolve(@Nullable Object value) {
}

@Override
public void reject(Throwable reason) {
public void reject(@NonNull Throwable reason) {
TurboLog.Companion.i("ReactNative", String.format("Reply FAILED exception %s", reason.getMessage()));
onReplyFailed(notificationId);
}

@Override
public void reject(String code, String message) {
public void reject(@NonNull String code, String message) {
TurboLog.Companion.i("ReactNative",
String.format("Reply FAILED status %s BODY %s", code, message)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static Bundle send(final String ackId, final String serverUrl, final Stri
JSONObject jsonResponse = new JSONObject(responseBody);
return parseAckResponse(jsonResponse);
} catch (Exception e) {
TurboLog.Companion.e("ReactNative", "Send receipt delivery failed " + e.getMessage());
e.printStackTrace();
return null;
}
Expand Down
16 changes: 8 additions & 8 deletions app/screens/home/recent_mentions/recent_mentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,19 @@ const RecentMentionsScreen = ({appsEnabled, customEmojiNames, mentions, currentT
return (
<Freeze freeze={!isFocused}>
<ExtraKeyboardProvider>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
subtitle={subtitle}
title={title}
hasSearch={false}
scrollValue={scrollValue}
/>
<SafeAreaView
style={styles.flex}
edges={EDGES}
testID='recent_mentions.screen'
>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
subtitle={subtitle}
title={title}
hasSearch={false}
scrollValue={scrollValue}
/>
<Animated.View style={[styles.flex, animated]}>
<Animated.View style={top}>
<RoundedHeaderContext/>
Expand Down
16 changes: 8 additions & 8 deletions app/screens/home/saved_messages/saved_messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ function SavedMessages({appsEnabled, posts, currentTimezone, customEmojiNames}:
return (
<Freeze freeze={!isFocused}>
<ExtraKeyboardProvider>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
subtitle={subtitle}
title={title}
hasSearch={false}
scrollValue={scrollValue}
/>
<SafeAreaView
edges={edges}
style={styles.flex}
testID='saved_messages.screen'
>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
subtitle={subtitle}
title={title}
hasSearch={false}
scrollValue={scrollValue}
/>
<Animated.View style={[styles.flex, animated]}>
<Animated.View style={top}>
<RoundedHeaderContext/>
Expand Down
38 changes: 19 additions & 19 deletions app/screens/home/search/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,31 +370,31 @@ const SearchScreen = ({teamId, teams, crossTeamSearchEnabled}: Props) => {

return (
<Freeze freeze={!isFocused}>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
title={intl.formatMessage({id: 'screen.search.title', defaultMessage: 'Search'})}
hasSearch={true}
scrollValue={scrollValue}
lockValue={lockValue}
hideHeader={hideHeader}
onChangeText={handleTextChange}
onSubmitEditing={onSubmit}
blurOnSubmit={true}
placeholder={intl.formatMessage({id: 'screen.search.placeholder', defaultMessage: 'Search messages & files'})}
onBlur={onBlur}
onClear={handleClearSearch}
onCancel={handleCancelSearch}
onFocus={onFocus}
defaultValue={searchValue}
ref={searchRef}
/>
<SafeAreaView
style={styles.flex}
edges={EDGES}
onLayout={onLayout}
testID='search_messages.screen'
>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
title={intl.formatMessage({id: 'screen.search.title', defaultMessage: 'Search'})}
hasSearch={true}
scrollValue={scrollValue}
lockValue={lockValue}
hideHeader={hideHeader}
onChangeText={handleTextChange}
onSubmitEditing={onSubmit}
blurOnSubmit={true}
placeholder={intl.formatMessage({id: 'screen.search.placeholder', defaultMessage: 'Search messages & files'})}
onBlur={onBlur}
onClear={handleClearSearch}
onCancel={handleCancelSearch}
onFocus={onFocus}
defaultValue={searchValue}
ref={searchRef}
/>
<KeyboardAvoidingView
style={styles.flex}
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ PODS:
- Yoga
- react-native-netinfo (11.4.1):
- React-Core
- react-native-network-client (1.8.1):
- react-native-network-client (1.8.2):
- Alamofire (~> 5.10.2)
- DoubleConversion
- glog
Expand Down Expand Up @@ -2518,7 +2518,7 @@ SPEC CHECKSUMS:
react-native-emm: f6003bebdf4fef4feef7c61f96a5c174f43c6b5f
react-native-image-picker: 130fad649d07e4eec8faaed361d3bba570e1e5ff
react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187
react-native-network-client: f2996a6440c422e64e787bdf8c8e3f992be1cee6
react-native-network-client: fdbd7f5f4c2818d6b90b4dcf9613d0a54ab41303
react-native-notifications: 3bafa1237ae8a47569a84801f17d80242fe9f6a5
react-native-paste-input: d33daa183942fa57f34dff2088805a60895f14d2
react-native-performance: 125a96c145e29918b55b45ce25cbba54f1e24dcd
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@mattermost/compass-icons": "0.1.48",
"@mattermost/hardware-keyboard": "file:./libraries/@mattermost/hardware-keyboard",
"@mattermost/react-native-emm": "1.5.1",
"@mattermost/react-native-network-client": "1.8.1",
"@mattermost/react-native-network-client": "1.8.2",
"@mattermost/react-native-paste-input": "0.8.1",
"@mattermost/react-native-turbo-log": "0.5.0",
"@mattermost/rnshare": "file:./libraries/@mattermost/rnshare",
Expand Down
Loading