remove contact-recovery

contact recovery is now handled by status-go

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2019-08-20 23:13:15 +02:00
parent 79ab816497
commit 5cafef6702
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
16 changed files with 6 additions and 178 deletions

View File

@ -1,86 +0,0 @@
(ns status-im.contact-recovery.core
"This namespace handles the case where a user has just recovered their account
and is not able to decrypt messages, as the encryption is device-to-device.
Upon receiving this message, an empty message is sent back carrying device information
which will tell the other peer to target this device as well"
(:require
[status-im.i18n :as i18n]
[re-frame.core :as re-frame]
[status-im.data-store.contact-recovery :as data-store.contact-recovery]
[status-im.utils.config :as config]
[status-im.utils.fx :as fx]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.contact.core :as models.contact]))
;; How long do we wait until we process a contact-recovery again?
(def contact-recovery-interval-ms (* 60 60 1000))
(defn prompt-dismissed! [public-key]
(re-frame/dispatch [:contact-recovery.ui/prompt-dismissed public-key]))
(defn prompt-accepted! [public-key]
(re-frame/dispatch [:contact-recovery.ui/prompt-accepted public-key]))
(defn handle-contact-recovery-fx
"Check that a contact-recovery for the given user is not already in process, if not
fetch from db and check"
[{:keys [db now] :as cofx} public-key]
(let [my-public-key (multiaccounts.model/current-public-key cofx)]
(when (and (not= public-key my-public-key)
(not (get-in db [:contact-recovery/pop-up public-key])))
{:db (update db :contact-recovery/pop-up conj public-key)
:contact-recovery/handle-recovery [now public-key]})))
(fx/defn prompt-dismissed [{:keys [db]} public-key]
{:db (update db :contact-recovery/pop-up disj public-key)})
(defn notified-recently?
"We don't want to notify the user each time, so we wait an interval before
sending a message again"
[now public-key]
(let [{:keys [timestamp]} (data-store.contact-recovery/get-contact-recovery-by-id public-key)]
(and timestamp
(> contact-recovery-interval-ms (- now timestamp)))))
(defn handle-recovery-fx [now public-key]
(if (notified-recently? now public-key)
(prompt-dismissed! public-key)
(re-frame/dispatch [:contact-recovery.callback/handle-recovery public-key])))
(fx/defn notify-user
"Send an empty message to the user, which will carry device information"
[cofx public-key]
(let [current-public-key (multiaccounts.model/current-public-key cofx)]
{:shh/send-direct-message
[{:src current-public-key
:dst public-key
:payload ""}]}))
(re-frame/reg-fx
:contact-recovery/handle-recovery
(fn [[now public-key]]
(handle-recovery-fx now public-key)))
(fx/defn save-contact-recovery [{:keys [now]} public-key]
{:data-store/tx [(data-store.contact-recovery/save-contact-recovery-tx {:timestamp now
:id public-key})]})
(fx/defn prompt-accepted [cofx public-key]
(fx/merge
cofx
(prompt-dismissed public-key)
(save-contact-recovery public-key)
(notify-user public-key)))
(fx/defn handle-recovery [{:keys [db] :as cofx} public-key]
(let [contact (models.contact/build-contact cofx public-key)
popup {:ui/show-confirmation {:title (i18n/label :t/contact-recovery-title {:name (:name contact)})
:content (i18n/label :t/contact-recovery-content {:name (:name contact)})
:confirm-button-text (i18n/label :t/notify)
:cancel-button-text (i18n/label :t/cancel)
:on-cancel #(prompt-dismissed! public-key)
:on-accept #(prompt-accepted! public-key)}}]
(if config/show-contact-recovery-pop-up?
(fx/merge cofx popup)
(prompt-accepted cofx public-key))))

View File

@ -1,17 +0,0 @@
(ns status-im.data-store.contact-recovery
(:require [status-im.data-store.realm.core :as core]))
(defn get-contact-recovery-by-id [public-key]
(core/realm-obj->clj (.objectForPrimaryKey @core/account-realm
"contact-recovery"
public-key)
:contact-recovery))
(defn save-contact-recovery-tx
"Returns tx function for saving a contact-recovery"
[contact-recovery]
(fn [realm]
(core/create realm
:contact-recovery
contact-recovery
true)))

View File

@ -18,7 +18,6 @@
[status-im.chat.models.input :as chat.input] [status-im.chat.models.input :as chat.input]
[status-im.chat.models.loading :as chat.loading] [status-im.chat.models.loading :as chat.loading]
[status-im.chat.models.message :as chat.message] [status-im.chat.models.message :as chat.message]
[status-im.contact-recovery.core :as contact-recovery]
[status-im.contact.block :as contact.block] [status-im.contact.block :as contact.block]
[status-im.contact.core :as contact] [status-im.contact.core :as contact]
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
@ -1517,25 +1516,6 @@
(pairing/disable installation-id) (pairing/disable installation-id)
(multiaccounts.update/send-multiaccount-update)))) (multiaccounts.update/send-multiaccount-update))))
;; Contact recovery module
(handlers/register-handler-fx
:contact-recovery.ui/prompt-accepted
[(re-frame/inject-cofx :random-id-generator)]
(fn [cofx [_ public-key]]
(contact-recovery/prompt-accepted cofx public-key)))
(handlers/register-handler-fx
:contact-recovery.ui/prompt-dismissed
(fn [cofx [_ public-key]]
(contact-recovery/prompt-dismissed cofx public-key)))
(handlers/register-handler-fx
:contact-recovery.callback/handle-recovery
[(re-frame/inject-cofx :random-id-generator)]
(fn [cofx [_ public-key]]
(contact-recovery/handle-recovery cofx public-key)))
(handlers/register-handler-fx (handlers/register-handler-fx
:stickers/load-sticker-pack-success :stickers/load-sticker-pack-success
(fn [cofx [_ edn-string id price open?]] (fn [cofx [_ edn-string id price open?]]

View File

@ -1,6 +1,5 @@
(ns status-im.signals.core (ns status-im.signals.core
(:require [status-im.chat.models.loading :as chat.loading] (:require [status-im.chat.models.loading :as chat.loading]
[status-im.contact-recovery.core :as contact-recovery]
[status-im.ethereum.subscriptions :as ethereum.subscriptions] [status-im.ethereum.subscriptions :as ethereum.subscriptions]
[status-im.mailserver.core :as mailserver] [status-im.mailserver.core :as mailserver]
[status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.model :as multiaccounts.model]
@ -44,7 +43,6 @@
"mailserver.request.completed" (mailserver/handle-request-completed cofx event) "mailserver.request.completed" (mailserver/handle-request-completed cofx event)
"mailserver.request.expired" (when (multiaccounts.model/logged-in? cofx) "mailserver.request.expired" (when (multiaccounts.model/logged-in? cofx)
(mailserver/resend-request cofx {:request-id (:hash event)})) (mailserver/resend-request cofx {:request-id (:hash event)}))
"messages.decrypt.failed" (contact-recovery/handle-contact-recovery-fx cofx (:sender event))
"discovery.summary" (summary cofx event) "discovery.summary" (summary cofx event)
"subscriptions.data" (ethereum.subscriptions/handle-signal cofx event) "subscriptions.data" (ethereum.subscriptions/handle-signal cofx event)
"subscriptions.error" (ethereum.subscriptions/handle-error cofx event) "subscriptions.error" (ethereum.subscriptions/handle-error cofx event)

View File

@ -24,7 +24,6 @@
:navigation-stack '(:multiaccounts) :navigation-stack '(:multiaccounts)
:contacts/contacts {} :contacts/contacts {}
:pairing/installations {} :pairing/installations {}
:contact-recovery/pop-up #{}
:qr-codes {} :qr-codes {}
:group/selected-contacts #{} :group/selected-contacts #{}
:chats {} :chats {}

View File

@ -20,7 +20,6 @@
(def bootnodes-settings-enabled? (enabled? (get-config :BOOTNODES_SETTINGS_ENABLED "1"))) (def bootnodes-settings-enabled? (enabled? (get-config :BOOTNODES_SETTINGS_ENABLED "1")))
(def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1"))) (def rpc-networks-only? (enabled? (get-config :RPC_NETWORKS_ONLY "1")))
(def show-contact-recovery-pop-up? (enabled? (get-config :SHOW_CONTACT_RECOVERY_POPUP)))
(def mailserver-confirmations-enabled? (enabled? (get-config :MAILSERVER_CONFIRMATIONS_ENABLED))) (def mailserver-confirmations-enabled? (enabled? (get-config :MAILSERVER_CONFIRMATIONS_ENABLED)))
(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0))) (def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0)))
(def pairing-popup-disabled? (enabled? (get-config :PAIRING_POPUP_DISABLED "0"))) (def pairing-popup-disabled? (enabled? (get-config :PAIRING_POPUP_DISABLED "0")))

View File

@ -1,29 +0,0 @@
(ns status-im.test.contact-recovery.core
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.utils.config :as config]
[status-im.contact-recovery.core :as contact-recovery]))
(deftest show-contact-recovery-fx
(let [public-key "pk"]
(testing "no contact-recovery in place"
(let [cofx {:now "now"
:db {:contact-recovery/pop-up #{}
:multiaccount {:settings {:pfs? true}}}}
actual (contact-recovery/handle-contact-recovery-fx cofx public-key)]
(testing "it sets the pop up as displayed"
(is (get-in actual [:db :contact-recovery/pop-up public-key])))
(testing "it adds an fx for fetching the contact"
(is (= ["now" public-key] (:contact-recovery/handle-recovery actual))))))
(testing "contact recovery is in place"
(let [actual (contact-recovery/handle-contact-recovery-fx {:db {:contact-recovery/pop-up #{public-key}}} public-key)]
(testing "it does nothing"
(is (not (:db actual)))
(is (not (:contact-recovery/show-contact-recovery-message actual))))))))
(deftest show-contact-recovery-message
(let [public-key "pk"]
(with-redefs [config/show-contact-recovery-pop-up? true]
(let [cofx {:db {}}
actual (contact-recovery/handle-recovery cofx public-key)]
(testing "it shows a pop up"
(is (:ui/show-confirmation actual)))))))

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,6 @@
[status-im.test.chat.models] [status-im.test.chat.models]
[status-im.test.chat.views.photos] [status-im.test.chat.views.photos]
[status-im.test.transport.filters.core] [status-im.test.transport.filters.core]
[status-im.test.contact-recovery.core]
[status-im.test.contacts.device-info] [status-im.test.contacts.device-info]
[status-im.test.data-store.chats] [status-im.test.data-store.chats]
[status-im.test.data-store.messages] [status-im.test.data-store.messages]
@ -96,7 +95,6 @@
'status-im.test.chat.models.message-content 'status-im.test.chat.models.message-content
'status-im.test.chat.views.photos 'status-im.test.chat.views.photos
'status-im.test.transport.filters.core 'status-im.test.transport.filters.core
'status-im.test.contact-recovery.core
'status-im.test.contacts.db 'status-im.test.contacts.db
'status-im.test.contacts.device-info 'status-im.test.contacts.device-info
'status-im.test.data-store.chats 'status-im.test.data-store.chats

View File

@ -240,8 +240,6 @@
"completed": "Completed", "completed": "Completed",
"disabled": "Disabled", "disabled": "Disabled",
"paired-devices": "Paired devices", "paired-devices": "Paired devices",
"contact-recovery-title": "{{name}} has sent you a message",
"contact-recovery-content": "{{name}} has sent you a message but did not include this device.\nThis might happen if you have more than 3 devices, you haven't paired your devices correctly or you just recovered your multiaccount.\nPlease make sure your devices are paired correctly and click Notify to let the user know of this device.",
"pairing-maximum-number-reached-title": "Max number of devices reached", "pairing-maximum-number-reached-title": "Max number of devices reached",
"pairing-maximum-number-reached-content": "Please disable one of your devices before enabling a new one.", "pairing-maximum-number-reached-content": "Please disable one of your devices before enabling a new one.",
"pairing-new-installation-detected-title": "New device detected", "pairing-new-installation-detected-title": "New device detected",

View File

@ -163,8 +163,6 @@
"connection-with-the-card-lost-text": "Pour continuer, maintenir la carte au dos de votre téléphone", "connection-with-the-card-lost-text": "Pour continuer, maintenir la carte au dos de votre téléphone",
"contact-already-added": "Le contact a déjà été ajouté", "contact-already-added": "Le contact a déjà été ajouté",
"contact-code": "Code de contact", "contact-code": "Code de contact",
"contact-recovery-content": "{{name}} a envoyé un message mais n'inclut pas ce périphérique. \n Cela peut se produire si vous avez plus de 3 appareils, si vous ne les avez pas correctement couplés ou si vous venez de récupérer votre multi-compte. \n Assurez-vous que vos périphériques sont correctement couplés et cliquez sur Notifier pour informer l'utilisateur de ce périphérique.",
"contact-recovery-title": "{{name}} a envoyé un message",
"contact-s": { "contact-s": {
"one": "contact", "one": "contact",
"other": "contacts" "other": "contacts"

View File

@ -162,8 +162,6 @@
"connection-with-the-card-lost-text": "セットアップを再開するにはカードをスマートフォンの背面に当てたままにしてください", "connection-with-the-card-lost-text": "セットアップを再開するにはカードをスマートフォンの背面に当てたままにしてください",
"contact-already-added": "連絡先は既に追加されています", "contact-already-added": "連絡先は既に追加されています",
"contact-code": "連絡先コード", "contact-code": "連絡先コード",
"contact-recovery-content": "{{name}}からメッセージが送信されましたが、この端末は含まれていませんでした。 \nこれは、3つ以上のデバイスがある場合、デバイスを正しくペアリングしていない場合、またはマルチアカウントを回復したばかりの場合に発生する可能性があります。 \nデバイスが正しくペアリングされていることを確認し、通知をクリックしてこのデバイスをユーザーに知らせてください。",
"contact-recovery-title": "{{name}}からメッセージが送信されました",
"contact-s": { "contact-s": {
"other": "の連絡先" "other": "の連絡先"
}, },

View File

@ -159,8 +159,6 @@
"connection-with-the-card-lost-text": "계속하려면, 카드를 스마트폰의 뒷면에 대주세요", "connection-with-the-card-lost-text": "계속하려면, 카드를 스마트폰의 뒷면에 대주세요",
"contact-already-added": "이미 추가되어 있는 연락처입니다.", "contact-already-added": "이미 추가되어 있는 연락처입니다.",
"contact-code": "연락처 코드", "contact-code": "연락처 코드",
"contact-recovery-content": "{{name}} 님이 메시지를 보냈으나, 이 기기에는 메시지가 포함되지 않았습니다. 이러한 문제는 동기화 된 기기가 3대를 초과하거나, 기기를 올바르게 페어링하지 않았거나, 지금 막 계정을 복구 한 경우에 발생할 수 있습니다. \n기기가 올바르게 페어링되어 있는지 확인해주시고, '알림'을 클릭하여 기기를 확인합니다",
"contact-recovery-title": "{{name}} 님이 메시지를 보냈습니다",
"contact-s": { "contact-s": {
"other": "연락처" "other": "연락처"
}, },

View File

@ -163,8 +163,6 @@
"connection-with-the-card-lost-text": "Для продолжения поднесите карту к задней панели телефона", "connection-with-the-card-lost-text": "Для продолжения поднесите карту к задней панели телефона",
"contact-already-added": "Контакт уже добавлен", "contact-already-added": "Контакт уже добавлен",
"contact-code": "Код контакта", "contact-code": "Код контакта",
"contact-recovery-content": "{{name}} отправил(а) вам сообщение, но не включил(а) это устройство.\nЭто может произойти, если у вас более 3-х устройств, вы не выполнили связывание устройств правильно или восстановили мультиаккаунт.\nУбедитесь, что ваши устройства связаны правильно, и нажмите кнопку Уведомление, чтобы сообщить пользователю об этом устройстве.",
"contact-recovery-title": "{{name}} отправил(а) вам сообщение",
"contact-s": { "contact-s": {
"zero": "", "zero": "",
"one": "контакт", "one": "контакт",

View File

@ -159,8 +159,6 @@
"connection-with-the-card-lost-text": "要继续,请将卡片放在手机背面", "connection-with-the-card-lost-text": "要继续,请将卡片放在手机背面",
"contact-already-added": "已添加该联系人", "contact-already-added": "已添加该联系人",
"contact-code": "联系码", "contact-code": "联系码",
"contact-recovery-content": "{{name}}已向您发送了一条消息,但未包含此设备。 \n如果您有超过3台设备未正确配对设备或刚恢复帐户则可能会发生这种情况。 \n请确保您的设备配对正确然后点击通知以告知用户此设备。",
"contact-recovery-title": "{{name}}已向您发送了一条消息",
"contact-s": { "contact-s": {
"other": "联系人" "other": "联系人"
}, },

View File

@ -160,8 +160,6 @@
"connection-with-the-card-lost-text": "", "connection-with-the-card-lost-text": "",
"contact-already-added": "已添加该联系人", "contact-already-added": "已添加该联系人",
"contact-code": "联系码", "contact-code": "联系码",
"contact-recovery-content": "{{name}}已向您发送了一条消息,但未包含此设备。 \n如果您有超过3台设备未正确配对设备或刚恢复帐户则可能会发生这种情况。 \n请确保您的设备配对正确然后点击通知以告知用户此设备。",
"contact-recovery-title": "{{name}}已向您发送了一条消息",
"contact-s": { "contact-s": {
"other": "联系人" "other": "联系人"
}, },