mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
[web] Skip GeoIpLookup on CE/SP (#34348)
The regression was introduced in 487e1767b8ac531588a272f0492a900c24162b33. GeoIp is not configured in CE/SP, yielding an error log when rendering the project list. GitOrigin-RevId: 55410611a5fef95daa5914a31969893107777593
This commit is contained in:
@@ -501,8 +501,13 @@ async function projectListPage(req, res, next) {
|
||||
let showInrGeoBanner = false
|
||||
let showLATAMBanner = false
|
||||
let recommendedCurrency
|
||||
const { countryCode, currencyCode } =
|
||||
await GeoIpLookup.promises.getCurrencyCode(req.ip)
|
||||
let countryCode
|
||||
let currencyCode
|
||||
if (isSaas) {
|
||||
const currencyData = await GeoIpLookup.promises.getCurrencyCode(req.ip)
|
||||
countryCode = currencyData.countryCode
|
||||
currencyCode = currencyData.currencyCode
|
||||
}
|
||||
|
||||
if (
|
||||
usersBestSubscription?.type === 'free' ||
|
||||
|
||||
@@ -91,6 +91,13 @@ async function getDetails(ip, callback) {
|
||||
if (!ip) {
|
||||
return callback(new Error('no ip passed'))
|
||||
}
|
||||
if (!settings.apis.geoIpLookup?.url) {
|
||||
logger.warn(
|
||||
{},
|
||||
'settings.apis.geoIpLookup.url is not configured, skipping lookup'
|
||||
)
|
||||
return
|
||||
}
|
||||
ip = ip.trim().split(' ')[0]
|
||||
const url = new URL(settings.apis.geoIpLookup.url)
|
||||
url.pathname += ip
|
||||
|
||||
@@ -467,6 +467,20 @@ describe('ProjectListController', function () {
|
||||
await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
||||
})
|
||||
|
||||
it('should look up geo IP in saas', async function (ctx) {
|
||||
ctx.Features.hasFeature.withArgs('saas').returns(true)
|
||||
ctx.res.render = () => {}
|
||||
await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
||||
expect(ctx.GeoIpLookup.promises.getCurrencyCode).to.have.been.calledOnce
|
||||
})
|
||||
|
||||
it('should not look up geo IP in a non-saas environment', async function (ctx) {
|
||||
ctx.Features.hasFeature.withArgs('saas').returns(false)
|
||||
ctx.res.render = () => {}
|
||||
await ctx.ProjectListController.projectListPage(ctx.req, ctx.res)
|
||||
expect(ctx.GeoIpLookup.promises.getCurrencyCode).to.not.have.been.called
|
||||
})
|
||||
|
||||
it('should send groupRole to customer.io for group admins', async function (ctx) {
|
||||
ctx.Features.hasFeature.withArgs('saas').returns(true)
|
||||
ctx.SubscriptionViewModelBuilder.promises.getUsersSubscriptionDetails.resolves(
|
||||
|
||||
Reference in New Issue
Block a user