Dilshan-H / Oblivion-Inverse

A Simple E-mail Tracker - Made with Flask, Setup under 30 minutes - Track your messages using your own platform!
https://dilshan-h.github.io/Oblivion-Inverse/
MIT License
28 stars 18 forks source link

Tracking Email based on the user's timezone! #3

Open kailashchoudhary11 opened 2 years ago

kailashchoudhary11 commented 2 years ago

Currently the emails are being tracked base on the timezone "Asia/Colombo" Instead we can track it using the timezone of the user!

kailashchoudhary11 commented 2 years ago

If this seems a valid issue, I would like to work on it!

Dilshan-H commented 2 years ago

At the moment, user has to manually edit routes.py to change their timezone. And it is documented within 'Installation' section of the readme. But, more feasible and efficient way can be implemented here. @kailashchoudhary11 you are welcome to propose your changes anytime 😊

saroshfarhan commented 2 years ago

@Dilshan-H isntead of using generatedOn = str(dt.now().astimezone(pytz.timezone('Asia/Colombo')))

can't we directly use generatedOn = str(dt.now().astimezone())

Won't this give the current timezone of the user? Just a doubt I read it here - GeeksforGeeks

Dilshan-H commented 2 years ago

@Dilshan-H isntead of using generatedOn = str(dt.now().astimezone(pytz.timezone('Asia/Colombo')))

can't we directly use generatedOn = str(dt.now().astimezone())

Won't this give the current timezone of the user? Just a doubt I read it here - GeeksforGeeks

If you are planning to host the application in a local environment, this works just fine. But when it comes to remote servers they are maybe located in different timezones. That's why we need to pass timezone parameter specifically. That way we can get the datetime according to our local time zone. Hope this clarifies you issue 😊

saroshfarhan commented 2 years ago

@Dilshan-H isntead of using generatedOn = str(dt.now().astimezone(pytz.timezone('Asia/Colombo'))) can't we directly use generatedOn = str(dt.now().astimezone()) Won't this give the current timezone of the user? Just a doubt I read it here - GeeksforGeeks

If you are planning to host the application in a local environment, this works just fine. But when it comes to remote servers they are maybe located in different timezones. That's why we need to pass timezone parameter specifically. That way we can get the datetime according to our local time zone. Hope this clarifies you issue 😊

Aah, didn't think of it that way, you're absolutely right. Just had one more doubt, do we really need to show the time of creation of thee tracker to the user? What purpose does that information serve and can we not use utc instead?

Dilshan-H commented 2 years ago

@saroshfarhan It's better to show that info as user can quickly refer their corresponding email at a later time. When there are lot of tracking links this might be useful in a way. Also I'm hoping to implement a search functionality inside tracking link list dashboard. So, a user can search for tracking links that were generated in a specific date for example.

Gamerited commented 2 years ago

Hey @Dilshan-H,

We could import tzlocal and could get the local time? You can try this on a separate python file.

we would require tzlocal

pip3 install tzlocal

from datetime import datetime as dt
import pytz
from tzlocal import get_localzone

generatedOn = str(dt.now().astimezone(pytz.timezone(str(get_localzone()))))
print(generatedOn)
kailashchoudhary11 commented 2 years ago

I think the better way would be to send the timezone from the browser using js!

Dilshan-H commented 2 years ago

I think the better way would be to send the timezone from the browser using js!

Actually that seems like a better way to achieve this.

Hey @Dilshan-H,

We could import tzlocal and could get the local time? You can try this on a separate python file.

we would require tzlocal

pip3 install tzlocal

from datetime import datetime as dt
import pytz
from tzlocal import get_localzone

generatedOn = str(dt.now().astimezone(pytz.timezone(str(get_localzone()))))
print(generatedOn)

It will produce the same issue as earlier isn't it? (When used in remote servers)

kailashchoudhary11 commented 2 years ago

I think the better way would be to send the timezone from the browser using js!

Actually that seems like a better way to achieve this.

So can you assign this to me

Gamerited commented 2 years ago

It will produce the same issue as earlier isn't it? (When used in remote servers)

It does only solve the backend time issue. Not when it runs on the server.