louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
58.26k stars 5.26k forks source link

Notification time issue. #5000

Closed basil-thgnet closed 2 weeks ago

basil-thgnet commented 2 months ago

⚠️ Please verify that this question has NOT been raised before.

🛡️ Security Policy

📝 Describe your problem

Hi,

The email notifications received from uptime-kuma has the time in UTC in its email headers instead of specifying the local time.

Is there a fix for it ?

Can we do something to sort this issue to dislapy the local time in email headers ?

I have checked deploying the application via both docker and without using docker.

Thank you.

📝 Error Message(s) or Log

No response

🐻 Uptime-Kuma Version

1.23.13

💻 Operating System and Arch

Ubuntu 20.04

🌐 Browser

Chrome Version 127.0.6533.99

🖥️ Deployment Environment

Runtime: Docker 20.10.9

CommanderStorm commented 2 months ago

nodemailer sets the current time as UTC in that field. Why do you want this field in local time?

basil-thgnet commented 2 months ago

if we receive a server downtime alert in email box from uptime-kuma, the email shows the local time which is in CEST, but the time in email header shows the time in UTC, which makes the person confused regarding the actual time the issue happened.

basil-thgnet commented 2 months ago

the last mail with monitoring is recevied on 10h50 it's the good time but in the mail :

Time (UTC): 2024-08-06 08:50:44.225

I have attached the screenshot.

How can i show the local time on email header too ? time

CommanderStorm commented 2 months ago

The screenshot included by you does not show a header.

That part of the notification shows the servers timezone and local time since 1.22.0. https://github.com/louislam/uptime-kuma/commit/343a1d3344779ea10933637cae1c0f46eadfd90b#diff-127e639176c0431697ef001140696f0bfb56aa113da83f20a9ffa26d450804e1

You can change the servers timezone in the settings

basil-thgnet commented 2 months ago

In smtp.js, i have changed:

bodyTextContent = ${msg}\nTime (CST): ${heartbeatJSON["time"]};

to

bodyTextContent = ${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]};

and still shows the same issue.

The email notification received from uptime-kuma is attached.

Please let me know how this can resolved. time

CommanderStorm commented 2 months ago

Double check your version and update. As said: this was changed as requested in v1.22.0..

PS: assuming you have made a typo in (UTC) above, otherwise talk to the person who forked/...

basil-thgnet commented 2 months ago

okay, let me check.

basil-thgnet commented 2 months ago

Hi,

1) The output of time/date


root@kuma-docker-server:~/uptime-kuma# timedatectl 
               Local time: Mon 2024-08-12 13:19:17 IST
               Universal time: Mon 2024-08-12 07:49:17 UTC
               RTC time: Mon 2024-08-12 07:49:17    
               Time zone: Asia/Kolkata (IST, +0530)  
System clock synchronized: yes                        
NTP service: active                     
RTC in local TZ: yes

2) The uptime-kuma version

root@kuma-docker-server:~/uptime-kuma# cat package.json | grep version
    "version": "1.23.13",

3) The email showing UTC time instead of IST

Return-Path: <basiludemy@gmail.com>
Received: from [127.0.0.1] ([193.105.133.252])
        by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c72d551sm179900655e9.2.2024.08.12.00.48.24
        for <basiludemy@gmail.com>
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Mon, 12 Aug 2024 00:48:24 -0700 (PDT)
From: basiludemy@gmail.com
To: basiludemy@gmail.com
Subject: Alert -Test
Message-ID: <55850fbc-7be1-fbf1-4e4f-8b2a543ed244@gmail.com>
Content-Transfer-Encoding: 7bit
Date: Mon, 12 Aug 2024 07:48:22 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8

My Email Alert (1) Testing

See the screenshots attached.

I cannot see that the time in notification has been rectified in the versions above v1.22.0, as the current version mine is v1.23.13.

Thank you. email kuma-version timedate

CommanderStorm commented 2 months ago

That does not match what you have reported previously. Here is the code for 1.23.X => no Time (CST) as reported here

https://github.com/louislam/uptime-kuma/blob/1185b259c2f171758e75d92e6843c5efec652f04/server/notification-providers/smtp.js#L94

What have you set here in the settings? image

The email showing UTC time instead of IST

That is a different part of the email. The Date-header is indeed set to UTC by nodemailer, but that is not the line (Time ...) you reported here. Brings us back to my intial question: Why do you want the headers (not message-content) in local time?

basil-thgnet commented 2 months ago

hi,

the code in the smtp.js for the version "1.23.13" is correct as shown below and in the screenshots attached.

           bodyTextContent = `${msg}\nTime (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`;

I have attached the screenshots, please have a check.

We need the time in email headers in local time as the techs in the monitoring a getting confused by the time said in email headers. time body

CommanderStorm commented 2 months ago

Why are your techs looking at the raw mail headers in the first place? Headers are not really meant for humans, rather for machines or programs. All email programs that I know of just convert times to localtime. Converting from UTC in the display layer (in this case: mail-program) has advantages by putting the blame of having incorrect timezone-handling upstream. See The Problem with Time & Timezones why I would like that handling as upsteam as possible.

The time is included in the body..

basil-thgnet commented 2 months ago

Thank you, it has been fixed now. Thank you for the support

github-actions[bot] commented 2 weeks ago

We are clearing up our old help-issues and your issue has been open for 60 days with no activity. If no comment is made and the stale label is not removed, this issue will be closed in 7 days.