Skip to content

Commit

Permalink
Merge pull request #1072 from Mygod/fix-anonymous-search
Browse files Browse the repository at this point in the history
fix: search while not logged in
  • Loading branch information
TurtIeSocks authored Nov 16, 2024
2 parents 4f3f4d2 + 9ddffcd commit d11cb12
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions server/src/graphql/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,20 +419,22 @@ const resolvers = {
case 'gyms': {
if (!perms.gyms) return []
const results = await Db.search('Gym', perms, args)
const webhook = Event.webhookObj[req.user.selectedWebhook]
if (webhook?.nominatimUrl && results.length) {
const withFormatted = await Promise.all(
results.map(async (result) => ({
...result,
formatted: await geocoder(
webhook.nominatimUrl,
{ lat: result.lat, lon: result.lon },
true,
webhook.addressFormat,
),
})),
)
return withFormatted
if (req.user?.selectedWebhook) {
const webhook = Event.webhookObj[req.user.selectedWebhook]
if (webhook?.nominatimUrl && results.length) {
const withFormatted = await Promise.all(
results.map(async (result) => ({
...result,
formatted: await geocoder(
webhook.nominatimUrl,
{ lat: result.lat, lon: result.lon },
true,
webhook.addressFormat,
),
})),
)
return withFormatted
}
}
return results
}
Expand Down

0 comments on commit d11cb12

Please sign in to comment.