Saturday, June 25, 2016

Should message timestamps be the time the message was sent or the time the server recieved it?


I have a service where messages may be created (and put in a "send" queue) even when there's no connection to the server. When the messages are sent to the server after successfully connecting, should the "message sent time" be set when the server got the message or when it was actually composed by the user?



Answer



Letting the client determine the timestamp seems open to abuse. How do you know the user's clock is set correctly? Gizmodo claims that 1.9% of Android devices are 1 hour fast, and not just for innocuous reasons:



Coin Dozer is styled as an old-style fair/arcade game in which coins are pushed onto a table where they can bump other coins off into a collection tray. The user starts with a finite number of coins, more coins can be won to continue playing, additionally every 30s a coin is generated. If all coins run out by falling off the wrong side, the user must wait for a coin to be generated. This is a cunning technique to encourage users to keep the app open, which will increase ad revenue for the creators.


A cheat was discovered on Android and iOS that involves manually advancing the system clock to fool Coin Dozer and gain coins more rapidly. Since the system time on both iOS and Android is altered by scrolling through numbers, the quickest adjustment is to alter the clock by one hour, one day, or one minute. The cheats generally recommend an hour or a day in order to generate a full complement of coins.




If the messages being sent are in any way time sensitive, can be gamed, or has anything to do with finances, you can only rely on the time the server received the message. If the messages are just harmless bits of text, it may be safe to use the queued time. Just keep in mind that times won't be entirely accurate.


It is worth noting that email clients do not count messages as being "sent" until they have been successfully delivered to the mail server.


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...