aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-10-15 11:40:05 +0300
committerKostya <mail@sartin.in>2026-10-15 11:40:30 +0300
commit4563c9d6d6c1576b6fb45899c2b6d6073966d8b8 (patch)
tree2138d35b626f7aadfa458a855722c8bd053cd815 /api
parent6968a0105ad521d7b86b15555f8f627094a59725 (diff)
downloadguess-market-4563c9d6d6c1576b6fb45899c2b6d6073966d8b8.tar.gz
guess-market-4563c9d6d6c1576b6fb45899c2b6d6073966d8b8.tar.xz
guess-market-4563c9d6d6c1576b6fb45899c2b6d6073966d8b8.zip
server: add a chat shared by everyone logged in
Ex3 bonus. POST /api/chat says a line as the logged-in user and GET /api/chat?since=N returns the lines after id N, so a polling client only ever downloads what it has not seen. The last 500 lines are kept in memory. A chat line does not change the market, so the lock filter does not bump the market version for it; otherwise every line would make every client refetch all events. Also read form fields as UTF-8 in the filter rather than relying on Tomcat's default, since names and chat text may not be ASCII.
Diffstat (limited to 'api')
-rw-r--r--api/src/main/java/market/guess/model/chat/ChatMessageDTO.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/api/src/main/java/market/guess/model/chat/ChatMessageDTO.java b/api/src/main/java/market/guess/model/chat/ChatMessageDTO.java
new file mode 100644
index 0000000..72c439a
--- /dev/null
+++ b/api/src/main/java/market/guess/model/chat/ChatMessageDTO.java
@@ -0,0 +1,4 @@
1package market.guess.model.chat;
2
3/** One line of the server-wide chat. Ids grow by one, so a client asks for "everything after id". */
4public record ChatMessageDTO(long id, String at, String sender, String text) {}