aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/api/PM.java
diff options
context:
space:
mode:
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;