Cap maximum number of days requested to mailserver
Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
parent
810ca1f93a
commit
a313557694
|
@ -253,7 +253,7 @@
|
|||
(let [wnode (models.mailserver/fetch-current cofx)
|
||||
web3 (:web3 db)
|
||||
now-in-s (quot now 1000)
|
||||
last-request (or
|
||||
last-request (max
|
||||
(get-in db [:account/account :last-request])
|
||||
(- now-in-s seven-days))
|
||||
request-messages-topics (get-request-messages-topics db)
|
||||
|
|
|
@ -81,10 +81,16 @@
|
|||
cofx {:db db :now 1000000000}]
|
||||
(testing "inbox is ready"
|
||||
(testing "last-request is set"
|
||||
(let [cofx-with-last-request (assoc-in cofx [:db :account/account :last-request] 2)
|
||||
actual (inbox/request-messages cofx-with-last-request)]
|
||||
(testing "it uses last request"
|
||||
(is (= 2 (get-in actual [::inbox/request-messages :from]))))))
|
||||
(testing "last request is > the 7 days ago"
|
||||
(let [cofx-with-last-request (assoc-in cofx [:db :account/account :last-request] 400000)
|
||||
actual (inbox/request-messages cofx-with-last-request)]
|
||||
(testing "it uses last request"
|
||||
(is (= 400000 (get-in actual [::inbox/request-messages :from]))))))
|
||||
(testing "last request is < the 7 days ago"
|
||||
(let [cofx-with-last-request (assoc-in cofx [:db :account/account :last-request] 2)
|
||||
actual (inbox/request-messages cofx-with-last-request)]
|
||||
(testing "it uses last 7 days"
|
||||
(is (= 395200 (get-in actual [::inbox/request-messages :from])))))))
|
||||
(testing "last-request is not set"
|
||||
(let [actual (inbox/request-messages cofx)]
|
||||
(testing "it defaults to the last 7 days"
|
||||
|
|
Loading…
Reference in New Issue