Skip to content

Commit

Permalink
add: move claimqueue logic to enrollmentsession
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpy committed May 27, 2020
1 parent 6f57e20 commit be17c67
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/server/verification/processor/EnrollmentSession.js
@@ -1,7 +1,7 @@
// @flow
import { bindAll, omit } from 'lodash'
import { type IEnrollmentEventPayload } from './typings'

import { ClaimQueue } from '../../claimQueue/claimQueueAPI'
import logger from '../../../imports/logger'

const log = logger.child({ from: 'EnrollmentSession' })
Expand Down Expand Up @@ -101,6 +101,7 @@ export default class EnrollmentSession {
log.info('Whitelistening user:', loggedInAs)

await Promise.all([
ClaimQueue.setWhitelisted(user, storage, log),
adminApi.whitelistUser(gdAddress, profilePublickey),
storage.updateUser({ identifier: loggedInAs, isVerified: true })
])
Expand Down
10 changes: 0 additions & 10 deletions src/server/verification/verificationAPI.js
Expand Up @@ -117,16 +117,6 @@ const setup = (app: Router, verifier: VerificationAPI, storage: StorageAPI) => {
if (conf.claimQueueAllowed > 0 && isApprovedToClaim === false)
throw new Error('User not approved to claim, not in queue or still pending')
enrollmentResult = await enrollmentProcessor.enroll(user, enrollmentIdentifier, payload, log)
//if user has passed, then we mark that in claim queue and tag the user
if (enrollmentResult.isVerified) {
await Promise.all([
user.claimQueue &&
storage.updateUser({ identifier: user.identifier, 'claimQueue.status': 'whitelisted' }),
Mautic.addContactsToSegment([user.mauticId], conf.mauticClaimQueueWhitelistedSegmentId).catch(e => {
log.error('Failed Mautic adding user to claim queue whitelisted segment', { errMessage: e.message, e })
})
])
}
}
} catch (exception) {
const { message } = exception
Expand Down

0 comments on commit be17c67

Please sign in to comment.