Add pairing docs link, disable pfs toggle in release

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2019-01-30 11:11:03 +01:00
parent 7985ee838e
commit 89725d693a
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
15 changed files with 195 additions and 174 deletions

1
.env
View File

@ -12,6 +12,7 @@ LOG_LEVEL_STATUS_GO=info
LOG_LEVEL=debug
MAILSERVER_CONFIRMATIONS_ENABLED=0
PFS_ENCRYPTION_ENABLED=1
PFS_TOGGLE_VISIBLE=1
POW_TARGET=0.002
POW_TIME=1
RN_BRIDGE_THRESHOLD_WARNINGS=0

View File

@ -10,6 +10,7 @@ LOG_LEVEL=debug
MAILSERVER_CONFIRMATIONS_ENABLED=0
PAIRING_POPUP_DISABLED=1
PFS_ENCRYPTION_ENABLED=1
PFS_TOGGLE_VISIBLE=1
POW_TARGET=0.002
POW_TIME=1
RN_BRIDGE_THRESHOLD_WARNINGS=0

View File

@ -12,6 +12,7 @@ LOG_LEVEL=debug
MAILSERVER_CONFIRMATIONS_ENABLED=0
MAINNET_WARNING_ENABLED=1
PFS_ENCRYPTION_ENABLED=1
PFS_TOGGLE_VISIBLE=1
POW_TARGET=0.002
POW_TIME=1
RN_BRIDGE_THRESHOLD_WARNINGS=0

View File

@ -10,6 +10,7 @@ LOG_LEVEL=debug
MAILSERVER_CONFIRMATIONS_ENABLED=0
MAINNET_WARNING_ENABLED=1
PFS_ENCRYPTION_ENABLED=1
PFS_TOGGLE_VISIBLE=1
POW_TARGET=0.002
POW_TIME=1
RN_BRIDGE_THRESHOLD_WARNINGS=0

View File

@ -10,6 +10,7 @@ LOG_LEVEL=debug
MAILSERVER_CONFIRMATIONS_ENABLED=0
MAINNET_WARNING_ENABLED=1
PFS_ENCRYPTION_ENABLED=1
PFS_TOGGLE_VISIBLE=1
POW_TARGET=0.002
POW_TIME=1
RN_BRIDGE_THRESHOLD_WARNINGS=0

View File

@ -9,6 +9,7 @@ LOG_LEVEL_STATUS_GO=
LOG_LEVEL=info
MAINNET_WARNING_ENABLED=1
PFS_ENCRYPTION_ENABLED=1
PFS_TOGGLE_VISIBLE=0
POW_TARGET=0.002
POW_TIME=1
RN_BRIDGE_THRESHOLD_WARNINGS=0

View File

@ -13,7 +13,7 @@
[status-im.contact.core :as models.contact]))
;; How long do we wait until we process a contact-recovery again?
(def contact-recovery-interval-ms (* 6 60 60 1000))
(def contact-recovery-interval-ms (* 60 60 1000))
(defn prompt-dismissed! [public-key]
(re-frame/dispatch [:contact-recovery.ui/prompt-dismissed public-key]))
@ -40,10 +40,11 @@
[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)))))
(> contact-recovery-interval-ms (- now timestamp)))))
(defn handle-recovery-fx [now public-key]
(when-not (notified-recently? 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

View File

@ -74,7 +74,7 @@
[{:keys [db] :as cofx} {:keys [payload chat-id success-event]}]
(let [{:keys [web3]} db]
(let [pfs? (get-in db [:account/account :settings :pfs?])]
(if pfs?
(if (and config/pfs-toggle-visible? pfs?)
(send-direct-message cofx
chat-id
success-event

View File

@ -87,6 +87,7 @@
[pairing.views/edit-installation-name]
[react/view
[pairing.views/pair-this-device]
[pairing.views/info-section]
[pairing.views/sync-devices]
[react/view {:style pairing.styles/installation-list}
[pairing.views/your-device your-installation-id your-installation-name]
@ -193,7 +194,7 @@
[react/view {:style styles/title-separator}]
[react/text {:style styles/adv-settings-subtitle} (i18n/label :t/pfs)]
[react/view {:style (styles/profile-row false)}
[react/text {:style (styles/profile-row-text colors/black)} (i18n/label :notifications)]
[react/text {:style (styles/profile-row-text colors/black)} (i18n/label :t/pfs)]
[react/switch {:on-tint-color colors/blue
:value pfs?
:on-value-change #(re-frame/dispatch [:accounts.ui/toggle-pfs (not pfs?)])}]]])))

View File

@ -44,6 +44,13 @@
:padding-top 12
:background-color :white})
(def info-section
{:padding-horizontal 16
:padding-top 12})
(def info-section-text
{:color colors/blue})
(def pair-this-device-actions
{:flex 1
:flex-direction :row})

View File

@ -177,6 +177,11 @@
(re-frame/dispatch [:pairing.ui/set-name-pressed @installation-name])
(reset! installation-name ""))}]]])
(defn info-section []
[react/view {:style styles/info-section}
[react/touchable-highlight {:on-press #(.openURL react/linking "https://status.im/tutorials/pairing.html")}
[react/text {:style styles/info-section-text} (i18n/label :t/learn-more)]]])
(defn installations-list [installation-id installation-name installations]
[react/view {:style styles/installation-list}
[react/view {:style styles/paired-devices-title}
@ -197,5 +202,6 @@
[edit-installation-name]
[react/view
[pair-this-device]
[info-section]
[installations-list installation-id installation-name installations]])]
(when (seq installations) [footer syncing])]))

View File

@ -200,9 +200,9 @@
{:label-kw :t/bootnodes
:action-fn #(re-frame/dispatch [:navigate-to :bootnodes-settings])
:accessibility-label :bootnodes-settings-button}])
(when dev-mode?
(when (and dev-mode? config/pfs-toggle-visible?)
[profile.components/settings-item-separator])
(when dev-mode?
(when (and dev-mode? config/pfs-toggle-visible?)
[profile.components/settings-switch-item
{:label-kw :t/pfs
:value (:pfs? settings)

View File

@ -23,6 +23,7 @@
(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0)))
(def pfs-encryption-enabled? (enabled? (get-config :PFS_ENCRYPTION_ENABLED "0")))
(def pairing-popup-disabled? (enabled? (get-config :PAIRING_POPUP_DISABLED "0")))
(def pfs-toggle-visible? (enabled? (get-config :PFS_TOGGLE_VISIBLE "0")))
(def cached-webviews-enabled? (enabled? (get-config :CACHED_WEBVIEWS_ENABLED 0)))
(def rn-bridge-threshold-warnings-enabled? (enabled? (get-config :RN_BRIDGE_THRESHOLD_WARNINGS 0)))
(def extensions-enabled? (enabled? (get-config :EXTENSIONS 0)))

View File

@ -29,176 +29,174 @@
(is (= 3 (group-chats/get-last-clock-value {:db {:chats {chat-id {:last-clock-value 3}}}} chat-id))))
(deftest handle-group-membership-update-test
(with-redefs [config/group-chats-enabled? true]
(testing "a brand new chat"
(let [actual (->
(group-chats/handle-membership-update {:now 0 :db {}} initial-message "payload" admin)
:db
:chats
(get chat-id))]
(testing "it creates a new chat"
(is actual))
(testing "it sets the right chat-name"
(is (= "chat-name"
(:name actual))))
(testing "it sets the right chat-id"
(is (= chat-id
(:chat-id actual))))
(testing "it sets the right participants"
(is (= #{member-1 member-2 member-3}
(:contacts actual))))
(testing "it sets the updates"
(is (= (:membership-updates initial-message)
(:membership-updates actual))))
(testing "it sets the right admins"
(is (= #{admin}
(:admins actual))))
(testing "it adds a system message"
(is (= 3 (count (:messages actual)))))
(testing "it adds the right text"
(is (= ["group-chat-created"
"group-chat-member-added"
"group-chat-member-added"]
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual)))))))))
(testing "a chat with the wrong id"
(let [bad-chat-id (str random-id member-2)
actual (->
(group-chats/handle-membership-update
{:now 0 :db {}}
(assoc initial-message :chat-id bad-chat-id)
"payload"
admin)
:db
:chats
(get bad-chat-id))]
(testing "it does not create a chat"
(is (not actual)))))
(testing "an already existing chat"
(let [cofx (assoc
(group-chats/handle-membership-update {:now 0 :db {:account/account {:public-key member-3}}} initial-message "payload" admin)
:now 0)]
(testing "the message has already been received"
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
(testing "it noops"
(is (=
(get-in cofx [:db :chats chat-id])
(get-in actual [:db :chats chat-id]))))))
(testing "a chat we have deleted"
(let [after-leaving-cofx (-> (group-chats/handle-membership-update cofx
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-3
:events [{:type "member-removed"
:clock-value 12
:member member-3}]}]}
"payload"
member-3)
(assoc-in [:db :chats chat-id :is-active] false))
after-been-invited-again-cofx (group-chats/handle-membership-update (assoc after-leaving-cofx :now 0)
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-2
:events [{:type "members-added"
:clock-value 13
:members [member-3]}]}]}
"payload"
member-2)]
(testing "a brand new chat"
(let [actual (->
(group-chats/handle-membership-update {:now 0 :db {}} initial-message "payload" admin)
:db
:chats
(get chat-id))]
(testing "it creates a new chat"
(is actual))
(testing "it sets the right chat-name"
(is (= "chat-name"
(:name actual))))
(testing "it sets the right chat-id"
(is (= chat-id
(:chat-id actual))))
(testing "it sets the right participants"
(is (= #{member-1 member-2 member-3}
(:contacts actual))))
(testing "it sets the updates"
(is (= (:membership-updates initial-message)
(:membership-updates actual))))
(testing "it sets the right admins"
(is (= #{admin}
(:admins actual))))
(testing "it adds a system message"
(is (= 3 (count (:messages actual)))))
(testing "it adds the right text"
(is (= ["group-chat-created"
"group-chat-member-added"
"group-chat-member-added"]
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual)))))))))
(testing "a chat with the wrong id"
(let [bad-chat-id (str random-id member-2)
actual (->
(group-chats/handle-membership-update
{:now 0 :db {}}
(assoc initial-message :chat-id bad-chat-id)
"payload"
admin)
:db
:chats
(get bad-chat-id))]
(testing "it does not create a chat"
(is (not actual)))))
(testing "an already existing chat"
(let [cofx (assoc
(group-chats/handle-membership-update {:now 0 :db {:account/account {:public-key member-3}}} initial-message "payload" admin)
:now 0)]
(testing "the message has already been received"
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
(testing "it noops"
(is (=
(get-in cofx [:db :chats chat-id])
(get-in actual [:db :chats chat-id]))))))
(testing "a chat we have deleted"
(let [after-leaving-cofx (-> (group-chats/handle-membership-update cofx
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-3
:events [{:type "member-removed"
:clock-value 12
:member member-3}]}]}
"payload"
member-3)
(assoc-in [:db :chats chat-id :is-active] false))
after-been-invited-again-cofx (group-chats/handle-membership-update (assoc after-leaving-cofx :now 0)
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-2
:events [{:type "members-added"
:clock-value 13
:members [member-3]}]}]}
"payload"
member-2)]
(testing "it sets the chat active after been invited again"
(is (get-in after-been-invited-again-cofx [:db :chats chat-id :is-active])))))
(testing "a new message comes in"
(let [actual (group-chats/handle-membership-update cofx
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-2
:events [{:type "member-removed"
:clock-value 12
:member member-3}
{:type "members-added"
:clock-value 12
:members [member-4]}
{:type "name-changed"
:clock-value 13
:name "new-name"}]}]}
"payload"
member-3)
actual-chat (get-in actual [:db :chats chat-id])]
(testing "the chat is updated"
(is actual-chat))
(testing "admins are updated"
(is (= #{member-2} (:admins actual-chat))))
(testing "members are updated"
(is (= #{member-1 member-2 member-4} (:contacts actual-chat))))
(testing "the name is updated"
(is (= "new-name" (:name actual-chat))))
(testing "it adds a system message"
(is (= 7 (count (:messages actual-chat)))))
(testing "it sets the right text"
(is (= ["group-chat-created"
"group-chat-member-added"
"group-chat-member-added"
"group-chat-admin-added"
"group-chat-member-added"
"group-chat-member-removed"
"group-chat-name-changed"]
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual-chat)))))))))))))
(testing "it sets the chat active after been invited again"
(is (get-in after-been-invited-again-cofx [:db :chats chat-id :is-active])))))
(testing "a new message comes in"
(let [actual (group-chats/handle-membership-update cofx
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-2
:events [{:type "member-removed"
:clock-value 12
:member member-3}
{:type "members-added"
:clock-value 12
:members [member-4]}
{:type "name-changed"
:clock-value 13
:name "new-name"}]}]}
"payload"
member-3)
actual-chat (get-in actual [:db :chats chat-id])]
(testing "the chat is updated"
(is actual-chat))
(testing "admins are updated"
(is (= #{member-2} (:admins actual-chat))))
(testing "members are updated"
(is (= #{member-1 member-2 member-4} (:contacts actual-chat))))
(testing "the name is updated"
(is (= "new-name" (:name actual-chat))))
(testing "it adds a system message"
(is (= 7 (count (:messages actual-chat)))))
(testing "it sets the right text"
(is (= ["group-chat-created"
"group-chat-member-added"
"group-chat-member-added"
"group-chat-admin-added"
"group-chat-member-added"
"group-chat-member-removed"
"group-chat-name-changed"]
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual-chat))))))))))))
(deftest set-up-topic
(with-redefs [config/group-chats-enabled? true]
(let [cofx {:now 0 :db {:account/account {:public-key admin}}}]
(testing "a brand new chat"
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
(testing "it sets up a topic"
(is (:shh/add-discovery-filters actual)))))
(testing "an existing chat"
(let [cofx (assoc cofx
:db
(:db (group-chats/handle-membership-update cofx initial-message "payload" admin)))
new-message {:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-1
:events [{:type "member-removed"
:clock-value 12
:member member-1}]}]}
actual (group-chats/handle-membership-update cofx new-message "payload" admin)]
(testing "it removes the topic"
(is (:shh/remove-filter actual))))))))
(let [cofx {:now 0 :db {:account/account {:public-key admin}}}]
(testing "a brand new chat"
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
(testing "it sets up a topic"
(is (:shh/add-discovery-filters actual)))))
(testing "an existing chat"
(let [cofx (assoc cofx
:db
(:db (group-chats/handle-membership-update cofx initial-message "payload" admin)))
new-message {:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-1
:events [{:type "member-removed"
:clock-value 12
:member member-1}]}]}
actual (group-chats/handle-membership-update cofx new-message "payload" admin)]
(testing "it removes the topic"
(is (:shh/remove-filter actual)))))))
(deftest build-group-test
(testing "only adds"

View File

@ -7,6 +7,7 @@
"public-chat": "Public chat",
"description": "Description",
"devices": "Devices",
"learn-more": "Learn more",
"pair": "Pair devices",
"pair-this-device": "Pair this device",
"pair-this-device-description": "Pair your devices to sync contacts and chats between them",