#3832 closed defect (fixed)
[PATCH] Lobby message timestamps improperly stored in GUI code
Reported by: | elexis | Owned by: | Josh |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 22 |
Component: | Multiplayer lobby | Keywords: | patch |
Cc: | Josh | Patch: | Phab:D514 |
Description (last modified by )
When playing a long game and returning to the lobby, lobby.js
polls all chatmessages received during that time.
These chatmessages don't contain a timestamp.
The spamfilter is applied to all of them and then naturally assumes that everyone spammed who sent more than 3 messages.
So don't apply the spamfilter when returning from the lobby and/or preferably fix the timestamps in XmppClient.cpp
.
Attachments (2)
Change History (21)
comment:1 by , 8 years ago
Owner: | set to |
---|
comment:2 by , 8 years ago
Keywords: | patch review added |
---|---|
Summary: | Lobby - Spam monitor filters most messages when returning from a game → [Patch] Lobby message timestamps improperly stored in GUI code |
This turned out to be a lot more complicated than I imagined. The server only sends timestamps for delayed messages, so we have to locally track timestamps for normal messages. It was being done in lobby.js, but lobby.js must be stateless because it is dynamically loaded/unloaded.
The attached patch fixes this by adding timestamps (in seconds since the GMT epoch) to every GUI message.
follow-up: 4 comment:3 by , 8 years ago
Thanks for coming up with a patch so quickly! :)
The patch works for me - the timestamps are correct (besides timezone) and the spam monitor doesn't filter messages incorrectly when returning from a game while still filtering current spammers.
Since the patch doesn't introduce any regressions and implements correct message timestamps, I'd be in favor of committing it (the coding style issues should be fixed). Details:
Logic:
timezone
doesn't work for me, shows me UTC timestamps while it should be UTC+1 (See #3350 and linked stuff).- Why that
TODO
foraddChatMessage
, isn't it general enough? - That other
TODO
in the spam-monitor: Can't we remove the early return and check formsg.time
instead ofDate.now()
? (Also it looks like 30 seconds, not 5) IMO the spam monitor behavior is weird anyway and could be fixed in a separate ticket
Coding Style:
time_t
->std::time_t
time
->std::time
std::time(NULL)
->std::time(nullptr)
? (as the function wants a pointer)- L942 missing newline before
{
- L114 L117
addChatMessage
-> would be nice to have every property in a single line imo (otherwise missing space before}
)
comment:4 by , 8 years ago
Thanks for the prompt and detailed review!
Replying to elexis:
timezone
doesn't work for me, shows me UTC timestamps while it should be UTC+1 (See #3350 and linked stuff).
This is the expected behavior. I'm converting it to GMT from localtime, otherwise things become inconsistent. I have updated the comments to be clearer in the updated patch. The idea is that internal representations should be locale-agnostic.
- Why that
TODO
foraddChatMessage
, isn't it general enough?
Almost every message from the XMPP backend gets converted to a visible chat message. IMO, there should be some way to simplify the mapping (eg. by directly calling addChatMessage
with the message). However, my comment was too vague and has been removed in the updated patch.
- That other
TODO
in the spam-monitor: Can't we remove the early return and check formsg.time
instead ofDate.now()
? (Also it looks like 30 seconds, not 5) IMO the spam monitor behavior is weird anyway and could be fixed in a separate ticket
msg.time
exists on all messages now, so an explicit check is required. The incorrect number of seconds is fixed in the updated patch. Also, the TODO refers to how the spam monitor doesn't properly handle historical messages from a compromised client. The comment has been clarified in my updated patch.
time_t
->std::time_t
time
->std::time
std::time(NULL)
->std::time(nullptr)
? (as the function wants a pointer)
I have been writing a lot of C lately, so this seems rather foreign to me. If it's not too much trouble, could you elaborate on why this is convention?
- L942 missing newline before
{
- L114 L117
addChatMessage
-> would be nice to have every property in a single line imo (otherwise missing space before}
)
Fixed point 2 in updated patch, point 1 would be inconsistent with the style used in g_NetMessageTypes
for example.
by , 8 years ago
Attachment: | t3832-fix-lobby-timestamps.diff added |
---|
Rework lobby message timestamp handling (v2)
comment:5 by , 8 years ago
Whitespace:
- Still missing space (or newlines) in L122
- Still missing newline in L943 (
XmppClient::ComputeTimestamp
, how is that related to 'g_NetMessageTypes` ?) ComputeTimestamp
could use newlines before the comments imo
Logic:
- if you'd remove that 5 second check, woudln't it just work too for historical messages?
Random ignorable comments:
- Removed TODO: there are only three GUIMessage types which show a chat message without condition, so not sure if its worth it to add a new message queue for chatmessages
- since the code used
std::string
andstd::wstring
everywhere, I thought it would be more coherent to also usestd::time()
andstd::size_t
, but apparently thats not always the case in the code, so whatever
- ok to have internal timestamps in GMT, but displayed ones should be in the local timezone, so in that case we should fix that GUI function maybe (#3350)
comment:7 by , 8 years ago
Keywords: | review removed |
---|
Thanks for looking at the Xmpp backend and writing, testing a patch that quickly!
The spammonitor was already correctly working with your patch, just changed the number 5 to that spamblock-constant, so that rejoining the lobby doesn't unblock spammers. Also fixed the whitespace issues.
The displaying of timestamps in a wrong timezone was addressed in r17929 / #3350.
NOTICE: The removal of L894-905 should have been committed in r17928 instead of r17929.
comment:8 by , 8 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
The patch doesn't compile on windows as strptime
isn't resolved. Apparently wposix
implements it, but I don't know yet how to acccess it.
comment:9 by , 8 years ago
Should work if you make sure that source/lib/sysdep/os/win/wposix/wtime.cpp
is included.
comment:11 by , 8 years ago
Milestone: | Alpha 20 → Alpha 21 |
---|
Attaching a patch including the reverted code and some improvements. It's still needed to make that return call in ComputeTimestamp
nicer so we make clear that we return a UTC timestamp.
by , 8 years ago
Attachment: | t3832-post-revert.patch added |
---|
comment:12 by , 8 years ago
Summary: | [Patch] Lobby message timestamps improperly stored in GUI code → [PATCH] Lobby message timestamps improperly stored in GUI code |
---|
comment:13 by , 8 years ago
As far as I can see, the only reason why the post-revert patch isn't committed is #3848. If u64 can be used, we don't need a CTime
as proposed in comment:5:ticket:3350.
comment:15 by , 7 years ago
Description: | modified (diff) |
---|---|
Milestone: | Backlog → Alpha 22 |
Patch: | → Phab:D514 |
treegb2: ?
treegb2: who is pinging me?
treegb2: some history message is lost when I get in lobby again
Phab:D512 proposes to remove the broken spamfilter entirely becaue it should be filtered on the ejabberd + moderator level to begin with.
Postponed is not abandoned. Phab:D514 proposes to fix this by reverting the revert, as the patch was correct besides missing a #include "lib/sysdep/os/win/wposix/wtime.h"
and using std::time_t
(see Phab:D205).
Hmmm, that's an odd bug. I'm surprised that we lose the timestamps somewhere along the way (as they're maintained server-side).
I'm on break right now, so I'll take a quick look....