merge: fix exception when logging IP addresses (!644)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/644

Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
dakkar 2024-10-02 17:59:03 +00:00
commit a357e9bca2

View file

@ -260,6 +260,11 @@ export class ApiCallService implements OnApplicationShutdown {
const meta = await this.metaService.fetch();
if (!meta.enableIpLogging) return;
const ip = request.ip;
if (!ip) {
this.logger.warn(`user ${user.id} has a null IP address; please check your network configuration.`);
return;
}
const ips = this.userIpHistories.get(user.id);
if (ips == null || !ips.has(ip)) {
if (ips == null) {