nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.28k stars 4.06k forks source link

Display Share Expiry Based on UTC Time #47176

Open alperozturk96 opened 2 months ago

alperozturk96 commented 2 months ago

⚠️ This issue respects the following points: ⚠️

Bug description

When user set the share expiration time, it's not expiring based on user's locale.

I shared a file at 26.07.2024 10:21 and set the expiration date to 29.07.2024 10:21. Default time, log time zone is Europe/Berlin. Server time is UTC. Locale is German. Language is English (US). Nextcloud version is v29.0.4.

29.07.2024 10:21 didn't expire.

OC_SHARE table

[
   {
       "accepted": 0,
       "attributes": null,
       "expiration": null,
       "file_source": 391,
       "file_target": "/black.jpeg",
       "hide_download": 0,
       "id": 1,
       "item_source": "391",
       "item_target": null,
       "item_type": "file",
       "label": "",
       "mail_send": 0,
       "note": null,
       "parent": null,
       "password": null,
       "password_by_talk": 0,
       "password_expiration_time": null,
       "permissions": 17,
       "share_name": null,
       "share_type": 3,
       "share_with": null,
       "stime": 1721982057,
       "token": "xGByxARNYoF42S5",
       "uid_initiator": "admin",
       "uid_owner": "admin"
   }
]

Details

"expiration" is null in OC_Share table however I set the expiration date.

Maybe these questions can help

  1. Why expiration is null in oc_share table when even user set the expiration date?
  2. Is expiration date calculation based on default_timezone or server time (always UTC)?
  3. For example, what will happen when user in GMT-3 and set expiration date exactly one day later for same hour for user in GMT+3? Is it going to expire one day later in GMT-3 or GMT+3 or UTC?

Possible Solution

We can hold in DB the timezone difference between UTC and timezone of the shared user and calculate the diff and expire in correct time zone. Therefore, we will not rely on the user's timezone, we will rely on the difference between server time and the timezone of the shared user.

Steps to reproduce

  1. Share file with expiration time
  2. Set user default time zone

Expected behavior

Share expiration time must be based on user's locale.

Nextcloud Server version

29.0.4

susnux commented 2 months ago

I think the expected behavior is to have the time in the users timezone that created the setting. If I am in UTC+1 and set it to 12:30, then a user in UTC+2 will see the expiring at 13:30 local time.

alperozturk96 commented 2 months ago

I think the expected behavior is to have the time in the users timezone that created the setting. If I am in UTC+1 and set it to 12:30, then a user in UTC+2 will see the expiring at 13:30 local time.

Exactly. We should expire based on the shared user's time zone, not the sharer's or the server's time zone.

skjnldsv commented 2 months ago

I think that would be an enhancement. It could be nice, but we need to discuss this.

The most important part is properly displaying how long before the share expires. We could do this with the new public sharing UI for 31 :thinking:

Just so you know, we already use the owner timezone (26.0.13, 27.1.8, 28.0.4 and 29.0.0) https://github.com/nextcloud/server/pull/43428

TODO

artonge commented 2 months ago

I was not able to reproduce. expiration in oc_share is populated with the correct expiration date, and take into account the user timezone.

If you can reproduce on latest master, please reopen with reproduction steps.

skjnldsv commented 2 months ago

Keeping opened because my TODO still stands :)