pyc-website
main website for pyc inc.
git clone https://9o.is/git/pyc-website.git
commit 0a691a143a8662fa10d92c31d1d18ceb309cda26 parent e37665f00817aa41a21bda8c6f5afd81517e4914 Author: Jul <jul@9o.is> Date: Wed, 3 Sep 2014 00:10:55 -0400 created 'upload' function for IdVerificationHelper Diffstat:
| M | src/main/scala/inc/pyc/rest/IdVerification.scala | | | 23 | +++++++++++++++++++++++ |
| M | src/main/scala/inc/pyc/snippet/UserSnip.scala | | | 13 | ++----------- |
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/src/main/scala/inc/pyc/rest/IdVerification.scala b/src/main/scala/inc/pyc/rest/IdVerification.scala @@ -106,6 +106,29 @@ object IdVerificationHelper { user.email.get, user.id.get, new java.util.Date().toString) } + + /** + * Uploads the pending files and returns + * if it was successful or not. + */ + def upload(service: S3): Boolean = + if(IdVerificationFiles.isEmpty) { + false + } else { + val statusCodes = IdVerificationFiles.get.map { fp => + service.createFile(fp.fileName, fp.file, fp.mimeType) + } map { + f => + import dispatch._ + f().getStatusCode() + } + + IdVerificationFiles(Nil) + + statusCodes.forall(_ == 200) + } + + /** * Notifies us of a new user requesting their * identification to be verified. diff --git a/src/main/scala/inc/pyc/snippet/UserSnip.scala b/src/main/scala/inc/pyc/snippet/UserSnip.scala @@ -406,18 +406,9 @@ class IdVerification extends AngularCurrentUser { import IdVerificationHelper._ val service = s3(createS3Folder(user)) + val success = upload(service) - val statusCodes = IdVerificationFiles.get.map { fp => - service.createFile(fp.fileName, fp.file, fp.mimeType) - } map { - f => - import dispatch._ - f().getStatusCode() - } - - IdVerificationFiles(Nil) - - if (statusCodes.forall(_ == 200)) { + if (success) { user.purchaseLimit(USAPurchaseLimit.D10k_?) user.update notifyIdentityRequest(user)