• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #13322

pending completion
#13322

push

circleci

web-flow
Merge pull request #3001 from mozilla/main

Merge `main` into `localization`

282 of 1768 branches covered (15.95%)

Branch coverage included in aggregate %.

451 of 451 new or added lines in 56 files covered. (100.0%)

959 of 4670 relevant lines covered (20.54%)

1.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/controllers/storeExposureScanData.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
import { createProfile, createScan, parseExposureScanData } from '../external/onerep.js'
6
import { setOnerepProfileId } from '../db/tables/subscribers.js'
7

8
/**
9
 * @typedef {{ success: false }} StoreExposureScanDataErrorResponse
10
 * @typedef {{ success: true }} StoreExposureScanDataSuccessResponse
11
 * @typedef {StoreExposureScanDataErrorResponse | StoreExposureScanDataSuccessResponse} StoreExposureScanDataResponse
12
 */
13

14
/** @type {import('express').RequestHandler<import('../external/onerep').ProfileData, StoreExposureScanDataResponse>} */
15
async function storeExposureScanData (req, res, next) {
16
  if (req.method !== 'POST' || !req.user) {
×
17
    return next()
×
18
  }
19
  if (typeof req.user.onerep_profile_id === 'number') {
×
20
    // Exposure scan data is already set for this user
21
    res.status(409).send({ success: false })
×
22
    return
×
23
  }
24
  const exposureScanInput = parseExposureScanData(req.body)
×
25
  if (exposureScanInput === null) {
×
26
    res.status(400).send({ success: false })
×
27
    return
×
28
  }
29

30
  try {
×
31
    const onerepProfileId = await createProfile(exposureScanInput)
×
32
    await createScan(onerepProfileId)
×
33
    await setOnerepProfileId(req.user, onerepProfileId)
×
34

35
    /** @type {StoreExposureScanDataSuccessResponse} */
36
    const successResponse = {
×
37
      success: true
38
    }
39
    res.json(successResponse)
×
40
    return
×
41
  } catch (ex) {
42
    res.status(500).send({ success: false })
×
43
  }
44
}
45

46
export { storeExposureScanData }
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc