From 554476ede9d3eed0170b2074dcc04a437302e873 Mon Sep 17 00:00:00 2001 From: Icaro Motta Date: Wed, 22 Mar 2023 08:59:32 -0300 Subject: [PATCH] Remove support for cancelling outgoing contact requests (#15415) Removes the feature that allows users to cancel outgoing contact requests (possible spam vector). From now on, the user who sent the contact request will only be able to see the notification in the pending state. It seems this feature will be revisited in the future, but for now the agreement is to do the simplest thing and remove it. Fixes https://github.com/status-im/status-mobile/issues/15357 Steps to test: - Send CR from A to B. - A should see a new notification in the pending state. - B should receive a notification. If B accepts the CR, then A's pending CR disappears. If B declines the CR, then A's notification stays pending forever. Note: As expected, A can swipe left->right to mark the outgoing pending notification as read or swipe right->left to delete it. --- .../notification/contact_requests/events.cljs | 36 +------- .../notification/contact_requests/view.cljs | 84 +++++++------------ status-go-version.json | 6 +- 3 files changed, 35 insertions(+), 91 deletions(-) diff --git a/src/status_im2/contexts/activity_center/notification/contact_requests/events.cljs b/src/status_im2/contexts/activity_center/notification/contact_requests/events.cljs index 5ae28cd683..63ede623f8 100644 --- a/src/status_im2/contexts/activity_center/notification/contact_requests/events.cljs +++ b/src/status_im2/contexts/activity_center/notification/contact_requests/events.cljs @@ -1,6 +1,5 @@ (ns status-im2.contexts.activity-center.notification.contact-requests.events - (:require [status-im2.contexts.activity-center.events :as ac-events] - [taoensso.timbre :as log] + (:require [taoensso.timbre :as log] [utils.re-frame :as rf])) (rf/defn accept-contact-request @@ -19,8 +18,7 @@ (log/error "Failed to accept contact-request" {:error error :event :activity-center.contact-requests/accept - :contact-id contact-id}) - nil) + :contact-id contact-id})) (rf/defn decline-contact-request {:events [:activity-center.contact-requests/decline]} @@ -38,32 +36,4 @@ (log/error "Failed to decline contact-request" {:error error :event :activity-center.contact-requests/decline - :contact-id contact-id}) - nil) - -(rf/defn cancel-outgoing-contact-request - {:events [:activity-center.contact-requests/cancel-outgoing]} - [{:keys [db]} {:keys [contact-id notification-id]}] - (when-let [notification (ac-events/get-notification db notification-id)] - {:json-rpc/call - [{:method "wakuext_cancelOutgoingContactRequest" - :params [{:id contact-id}] - :on-success #(rf/dispatch [:activity-center.contact-requests/cancel-outgoing-success - notification]) - :on-error #(rf/dispatch [:activity-center.contact-requests/cancel-outgoing-error contact-id - %])}]})) - -(rf/defn cancel-outgoing-contact-request-success - {:events [:activity-center.contact-requests/cancel-outgoing-success]} - [_ notification] - {:dispatch [:activity-center.notifications/reconcile - [(assoc notification :deleted true)]]}) - -(rf/defn cancel-outgoing-contact-request-error - {:events [:activity-center.contact-requests/cancel-outgoing-error]} - [_ contact-id error] - (log/error "Failed to cancel outgoing contact-request" - {:error error - :event :activity-center.contact-requests/cancel-outgoing - :contact-id contact-id}) - nil) + :contact-id contact-id})) diff --git a/src/status_im2/contexts/activity_center/notification/contact_requests/view.cljs b/src/status_im2/contexts/activity_center/notification/contact_requests/view.cljs index 1a74fdba9a..815ce6fe07 100644 --- a/src/status_im2/contexts/activity_center/notification/contact_requests/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/contact_requests/view.cljs @@ -1,12 +1,13 @@ (ns status-im2.contexts.activity-center.notification.contact-requests.view - (:require [quo2.core :as quo] - [react-native.gesture :as gesture] - [status-im2.constants :as constants] - [status-im2.contexts.activity-center.notification.common.style :as common-style] - [status-im2.contexts.activity-center.notification.common.view :as common] - [utils.datetime :as datetime] - [utils.i18n :as i18n] - [utils.re-frame :as rf])) + (:require + [quo2.core :as quo] + [react-native.gesture :as gesture] + [status-im2.constants :as constants] + [status-im2.contexts.activity-center.notification.common.style :as common-style] + [status-im2.contexts.activity-center.notification.common.view :as common] + [utils.datetime :as datetime] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) (defn- swipe-button-accept [{:keys [style]} _] @@ -22,24 +23,17 @@ :icon :i/placeholder :text (i18n/label :t/decline)}]) -(defn- swipe-button-cancel-pending - [{:keys [style]} _] - [common/swipe-button-container - {:style (common-style/swipe-danger-container style) - :icon :i/placeholder - :text (i18n/label :t/cancel)}]) - (defn- swipeable [{:keys [active-swipeable extra-fn notification]} child] - (let [{:keys [id author message last-message]} notification - {:keys [contact-request-state]} (or (:message notification) - (:last-message notification)) - {:keys [public-key]} (rf/sub [:multiaccount/contact]) - message (or message last-message)] + (let [{:keys [id author message]} notification + {:keys [contact-request-state]} message + {:keys [public-key]} (rf/sub [:multiaccount/contact]) + outgoing? (= public-key author)] (cond - (#{constants/contact-request-message-state-accepted - constants/contact-request-message-state-declined} - contact-request-state) + (or (#{constants/contact-request-message-state-accepted + constants/contact-request-message-state-declined} + contact-request-state) + (and outgoing? (= contact-request-state constants/contact-request-message-state-pending))) [common/swipeable {:left-button common/swipe-button-read-or-unread :left-on-press common/swipe-on-press-toggle-read @@ -49,33 +43,23 @@ :extra-fn extra-fn} child] - (= contact-request-state constants/contact-request-message-state-pending) - (if (= public-key author) - [common/swipeable - {:right-button swipe-button-cancel-pending - :right-on-press (fn [] - (rf/dispatch - [:activity-center.contact-requests/cancel-outgoing - {:contact-id (:from message) - :notification-id id}])) - :active-swipeable active-swipeable - :extra-fn extra-fn} - child] - [common/swipeable - {:left-button swipe-button-accept - :left-on-press #(rf/dispatch [:activity-center.contact-requests/accept id]) - :right-button swipe-button-decline - :right-on-press #(rf/dispatch [:activity-center.contact-requests/decline id]) - :active-swipeable active-swipeable - :extra-fn extra-fn} - child]) + (and (= contact-request-state constants/contact-request-message-state-pending) + (not outgoing?)) + [common/swipeable + {:left-button swipe-button-accept + :left-on-press #(rf/dispatch [:activity-center.contact-requests/accept id]) + :right-button swipe-button-decline + :right-on-press #(rf/dispatch [:activity-center.contact-requests/decline id]) + :active-swipeable active-swipeable + :extra-fn extra-fn} + child] :else child))) (defn- outgoing-contact-request-view [{:keys [notification set-swipeable-height]}] - (let [{:keys [id chat-id message last-message]} notification + (let [{:keys [chat-id message last-message]} notification {:keys [contact-request-state] :as message} (or message last-message)] (if (= contact-request-state constants/contact-request-message-state-accepted) [quo/activity-log @@ -99,17 +83,7 @@ :message {:body (get-in message [:content :text])} :items (case contact-request-state constants/contact-request-message-state-pending - [{:type :button - :subtype :danger - :key :button-cancel - :label (i18n/label :t/cancel) - :accessibility-label :cancel-contact-request - :on-press (fn [] - (rf/dispatch - [:activity-center.contact-requests/cancel-outgoing - {:contact-id (:from message) - :notification-id id}]))} - {:type :status + [{:type :status :subtype :pending :key :status-pending :blur? true diff --git a/status-go-version.json b/status-go-version.json index bea22e4a9c..708cb1a686 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "94cd1ec", - "commit-sha1": "94cd1ec", - "src-sha256": "1inm5x6wwfm2v45aq0jyaq52lw6hpgkyy82h3v1bh2bs7bl1yd26" + "version": "v0.139.0", + "commit-sha1": "9c1c01c66f652ad6ce6fd4bbfbc613cc7a292878", + "src-sha256": "15cbbzir3bddgdbrrc9pnwdrsahn7a2ihaab7mfz93r0dg3q110i" }