All checks were successful
/ build (map[dockerfile:./services/hasura/Dockerfile name:hasura]) (push) Successful in 2m24s
/ build (map[dockerfile:./services/api/Dockerfile name:api]) (push) Successful in 2m18s
/ build (map[dockerfile:./services/watchers/Dockerfile name:watchers]) (push) Successful in 2m17s
/ build (map[dockerfile:./services/web/Dockerfile name:web]) (push) Successful in 2m14s
/ build (map[dockerfile:./services/files/Dockerfile name:files]) (push) Successful in 2m16s
/ build (map[dockerfile:./services/tasks/Dockerfile name:tasks]) (push) Successful in 2m25s
/ build (map[dockerfile:./services/app/Dockerfile name:app]) (push) Successful in 1m2s
/ deploy (push) Successful in 20s
64 lines
1.3 KiB
JavaScript
64 lines
1.3 KiB
JavaScript
const async = require("async")
|
|
const { ctx } = require("@modjo/core")
|
|
const tasks = require("~/tasks")
|
|
|
|
module.exports = async function alertGeosync(params) {
|
|
const { addTask } = ctx.require("amqp")
|
|
const redis = ctx.require("redisHotGeodata")
|
|
|
|
const {
|
|
alertId,
|
|
coordinates,
|
|
userId,
|
|
deviceId,
|
|
notifyAround = false,
|
|
notifyRelatives = false,
|
|
isLast = false,
|
|
} = params
|
|
|
|
return async.parallel([
|
|
async () => {
|
|
if (coordinates && coordinates.length === 2) {
|
|
const [longitude, latitude] = coordinates
|
|
return redis.geoadd("alert", longitude, latitude, alertId)
|
|
}
|
|
},
|
|
|
|
async () =>
|
|
notifyAround &&
|
|
userId &&
|
|
deviceId &&
|
|
addTask(tasks.GEOCODE_ALERT, {
|
|
alertId,
|
|
userId,
|
|
deviceId,
|
|
coordinates,
|
|
}),
|
|
|
|
async () =>
|
|
notifyRelatives &&
|
|
userId &&
|
|
addTask(tasks.RELATIVE_ALERT, {
|
|
alertId,
|
|
userId,
|
|
}),
|
|
|
|
async () =>
|
|
coordinates &&
|
|
coordinates.length === 2 &&
|
|
addTask(tasks.GEOCODE_ALERT_GUESS_ADDRESS, {
|
|
alertId,
|
|
coordinates,
|
|
isLast,
|
|
}),
|
|
|
|
async () =>
|
|
coordinates &&
|
|
coordinates.length === 2 &&
|
|
addTask(tasks.GEOCODE_ALERT_WHAT3WORDS, {
|
|
alertId,
|
|
coordinates,
|
|
isLast,
|
|
}),
|
|
])
|
|
}
|