ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [4/5] incubator-ponymail git commit: preferences.lua should not save user account if the mail is not sent
Date Sat, 17 Dec 2016 19:25:28 GMT
preferences.lua should not save user account if the mail is not sent

This fixes #306

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/55a2658f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/55a2658f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/55a2658f

Branch: refs/heads/master
Commit: 55a2658f5713c093123d46acda5314c9b0c984f0
Parents: 54b7d52
Author: Sebb <sebb@apache.org>
Authored: Sat Dec 17 19:05:53 2016 +0000
Committer: Sebb <sebb@apache.org>
Committed: Sat Dec 17 19:05:53 2016 +0000

----------------------------------------------------------------------
 CHANGELOG.md             | 1 +
 site/api/preferences.lua | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/55a2658f/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 645366d..f0eb8e3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -81,6 +81,7 @@
 - API.md does not document all the stats.lua parameters (#115)
 - allow preferences to use non-default mail port (#303)
 - preferences.lua should not return list data if it was not requested (#305)
+- preferences.lua should not update the user account if the mail is not sent OK (#306)
 
 
 ## CHANGES in 0.9b:

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/55a2658f/site/api/preferences.lua
----------------------------------------------------------------------
diff --git a/site/api/preferences.lua b/site/api/preferences.lua
index b6552e1..71fbb8a 100644
--- a/site/api/preferences.lua
+++ b/site/api/preferences.lua
@@ -74,9 +74,6 @@ function handle(r)
         end
         
         local hash = r:md5(math.random(1,999999) .. os.time() .. account.cid)
-        account.credentials.altemail = account.credentials.altemail or {}
-        table.insert(account.credentials.altemail, { email = get.associate, hash = hash,
verified = false})
-        user.save(r, account, true)
         local scheme = "https"
         if r.port == 80 then
             scheme = "http"
@@ -115,6 +112,12 @@ Pony Mail - Email for Ponies and People.
             server = config.mailserver,
             port = config.mailport or nil -- if not specified, use the default
         }
+         -- only update the account if the mail was sent OK
+        if rv then
+            account.credentials.altemail = account.credentials.altemail or {}
+            table.insert(account.credentials.altemail, { email = get.associate, hash = hash,
verified = false})
+            user.save(r, account, true)
+        end
         r:puts(JSON.encode{requested = rv or er})
         return cross.OK
     end


Mime
View raw message