aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-23 17:48:25 +0300
committerGravatar Vitaly Takmazov2018-10-23 17:48:25 +0300
commit8e83a22012c2bee323eeeb3ae1384ac488741ebf (patch)
tree947f307ce94e926938b23427e60346e0c5d21c11 /juick-server/src/main/java/com/juick/server
parentcab7e26aea1ac9518ff6c625340de2b809eaed50 (diff)
Last seen
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r--juick-server/src/main/java/com/juick/server/CommandsManager.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPConnection.java5
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Service.java8
3 files changed, 14 insertions, 2 deletions
diff --git a/juick-server/src/main/java/com/juick/server/CommandsManager.java b/juick-server/src/main/java/com/juick/server/CommandsManager.java
index 597604c6..ade70dc9 100644
--- a/juick-server/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-server/src/main/java/com/juick/server/CommandsManager.java
@@ -77,6 +77,9 @@ public class CommandsManager {
private ImagesService imagesService;
public CommandResult processCommand(User user, String data, @Nonnull URI attachment) throws Exception {
+ if (!user.isAnonymous()) {
+ userService.updateLastSeen(user);
+ }
String strippedData = StringUtils.stripStart(data, null);
if (strippedData.startsWith("?OTR")) {
return CommandResult.fromString("?OTR Error: we are not using OTR");
diff --git a/juick-server/src/main/java/com/juick/server/XMPPConnection.java b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
index d03251a3..9c0c09e1 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPConnection.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPConnection.java
@@ -497,6 +497,11 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
int uid_to = 0;
if (!toJuick) {
uid_to = userService.getUIDbyName(username);
+ } else {
+ User visitor = userService.getUserByJID(p.getFrom().asBareJid().toEscapedString());
+ if (visitor != null) {
+ userService.updateLastSeen(visitor);
+ }
}
if (toJuick || uid_to > 0) {
diff --git a/juick-server/src/main/java/com/juick/server/api/Service.java b/juick-server/src/main/java/com/juick/server/api/Service.java
index 2938e9da..3cf3ac28 100644
--- a/juick-server/src/main/java/com/juick/server/api/Service.java
+++ b/juick-server/src/main/java/com/juick/server/api/Service.java
@@ -144,12 +144,16 @@ public class Service {
}
@GetMapping("/api/events")
public SseEmitter handle() throws IOException {
- logger.info("{} connected", UserUtils.getCurrentUser().getName());
+ User visitor = UserUtils.getCurrentUser();
+ logger.info("{} connected", visitor.getName());
+ if (!visitor.isAnonymous()) {
+ userService.updateLastSeen(visitor);
+ }
SseEmitter emitter = new SseEmitter(600000L);
Message service = new Message();
service.setService(true);
emitter.send(service);
- serverManager.getSessions().add(new ServerManager.EventSession(UserUtils.getCurrentUser(), emitter));
+ serverManager.getSessions().add(new ServerManager.EventSession(visitor, emitter));
emitter.onCompletion(() -> endSession(emitter));
emitter.onTimeout(() -> endSession(emitter));