UX: Show on IP lookup if MaxMind key is missing (#18993)

as discussed in https://meta.discourse.org/t/maxminddb-not-found-error/148512/7.
 
shows a warning to the admin if no license for maxmind is found
This commit is contained in:
MichaIng
2023-11-23 22:02:05 +01:00
committed by GitHub
parent c0216f85a8
commit c58a41cb3e
6 changed files with 24 additions and 3 deletions

View File

@ -11,8 +11,10 @@ class DiscourseIpInfo
end
def open_db(path)
@loc_mmdb = mmdb_load(File.join(path, "GeoLite2-City.mmdb"))
@asn_mmdb = mmdb_load(File.join(path, "GeoLite2-ASN.mmdb"))
unless GlobalSetting.maxmind_license_key.blank?
@loc_mmdb = mmdb_load(File.join(path, "GeoLite2-City.mmdb"))
@asn_mmdb = mmdb_load(File.join(path, "GeoLite2-ASN.mmdb"))
end
@cache = LruRedux::ThreadSafeCache.new(2000)
end
@ -105,6 +107,8 @@ class DiscourseIpInfo
message: "IP #{ip} could not be looked up in MaxMind GeoLite2-City database.",
)
end
else
ret[:no_license] = true
end
if @asn_mmdb