aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/api/PM.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-20 16:37:42 +0300
committerGravatar Vitaly Takmazov2018-11-20 16:37:42 +0300
commita3ec3587e1fa33e4e08da9783d9d66c55ac84550 (patch)
tree9311de2f6511421eefed3e2e10bc821d2179dbd4 /src/main/java/com/juick/server/api/PM.java
parentd2b04d9b719b79a35e90b1c5569722ba5cbf794b (diff)
avatar public url
Diffstat (limited to 'src/main/java/com/juick/server/api/PM.java')
-rw-r--r--src/main/java/com/juick/server/api/PM.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/com/juick/server/api/PM.java b/src/main/java/com/juick/server/api/PM.java
index 0c36fe00..e00a4c97 100644
--- a/src/main/java/com/juick/server/api/PM.java
+++ b/src/main/java/com/juick/server/api/PM.java
@@ -18,7 +18,9 @@
package com.juick.server.api;
import com.juick.Chat;
+import com.juick.Message;
import com.juick.User;
+import com.juick.server.www.WebApp;
import com.juick.service.component.MessageEvent;
import com.juick.model.AnonymousUser;
import com.juick.model.PrivateChats;
@@ -47,6 +49,8 @@ public class PM {
private PMQueriesService pmQueriesService;
@Inject
private ApplicationEventPublisher applicationEventPublisher;
+ @Inject
+ private WebApp webApp;
@RequestMapping(value = "/api/pm", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public List<com.juick.Message> doGetPM(
@@ -64,7 +68,9 @@ public class PM {
throw new HttpBadRequestException();
}
- return pmQueriesService.getPMMessages(visitor.getUid(), uid);
+ List<Message> msgs = pmQueriesService.getPMMessages(visitor.getUid(), uid);
+ msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarPublicUrl(m.getUser())));
+ return msgs;
}
@RequestMapping(value = "/api/pm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@@ -109,6 +115,7 @@ public class PM {
// TODO: ignore cnt param for now but make sure paging param will not be cnt
List<Chat> lastconv = pmQueriesService.getLastChats(visitor);
+ lastconv.forEach(c -> c.setAvatar(webApp.getAvatarPublicUrl(c)));
PrivateChats pms = new PrivateChats();
pms.setUsers(lastconv);
return pms;