devhub icon indicating copy to clipboard operation
devhub copied to clipboard

Timestamp of comment uses user's system time settings.

Open aaronang opened this issue 10 years ago • 8 comments

As you can see in the picture below, the timestamp of a comment uses the user's system time setting. I think it makes more sense to display the server time. time-difference

aaronang avatar Jun 17 '15 23:06 aaronang

Is this right after commenting (javascript) or after a page refresh?

jwgmeligmeyling avatar Jun 17 '15 23:06 jwgmeligmeyling

I see, after a page refresh it is correct :smile:

aaronang avatar Jun 17 '15 23:06 aaronang

I want to fix this some day but its not worth the effort at the moment. Comments are currently rendered by Freemarker and the date is formatted for the browsers preferred Locale. This is however difficult to integrate with the REST api used for posting the comments, therefore we use the JS current time as a quick fix.VLater on we will probably leave the rendering of the comments to AngularJS or Web components, which will also take over the date format.

jwgmeligmeyling avatar Jun 17 '15 23:06 jwgmeligmeyling

I guess I will leave this issue open?

aaronang avatar Jun 17 '15 23:06 aaronang

Yes that is OK, the inconsistency between the javascript injected comments and freemarker comments are a known issue though ;) And I might fix this when implementing Markdown (#149) but I first want to find out a better way to manage web dependencies.

Btw, I believe you can XSS some fancy colours into your comments by abusing this very same problem. You won't be able to harm others though ;)

jwgmeligmeyling avatar Jun 17 '15 23:06 jwgmeligmeyling

Not sure, but in class ProjectResource, I see a line which returns a CommentResponse with the date set to server time? This CommentResponse is returned to the AJAX call here. Afterwards you are creating the comment container here. This should display the server time right (res.date)? Or am I missing something? Where is the part where it sets the current time?

aaronang avatar Jun 18 '15 09:06 aaronang

The ProjectResource is responsible for the comment backend endpoint: https://github.com/devhub-tud/devhub/blob/master/src/main/java/nl/tudelft/ewi/devhub/server/web/resources/ProjectResource.java#L223 . It uses the toString of the date apparently.

jwgmeligmeyling avatar Jun 18 '15 09:06 jwgmeligmeyling

I am also confused by this haha. Maybe there is a difference in implementation between commit/pr comments and inline comments

jwgmeligmeyling avatar Jun 18 '15 09:06 jwgmeligmeyling