aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/juick/server/XMPPConnection.java2
-rw-r--r--src/main/java/com/juick/server/api/Messages.java10
-rw-r--r--src/main/java/com/juick/server/api/PM.java4
-rw-r--r--src/main/java/com/juick/server/api/Users.java12
-rw-r--r--src/main/java/com/juick/server/api/activity/Profile.java2
-rw-r--r--src/main/java/com/juick/server/api/rss/MessagesView.java2
-rw-r--r--src/main/java/com/juick/server/www/WebApp.java4
-rw-r--r--src/main/java/com/juick/server/www/controllers/MessagesWWW.java2
8 files changed, 17 insertions, 21 deletions
diff --git a/src/main/java/com/juick/server/XMPPConnection.java b/src/main/java/com/juick/server/XMPPConnection.java
index 74e281c9..444e2512 100644
--- a/src/main/java/com/juick/server/XMPPConnection.java
+++ b/src/main/java/com/juick/server/XMPPConnection.java
@@ -173,7 +173,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener {
userVCard.setFormattedName(info.getFullName());
userVCard.setNickname(user.getName());
try {
- userVCard.setPhoto(new VCard.Image(URI.create(webApp.getAvatarPublicUrl(user))));
+ userVCard.setPhoto(new VCard.Image(URI.create(webApp.getAvatarWebPath(user))));
if (info.getUrl() != null) {
userVCard.setUrl(new URL(info.getUrl()));
}
diff --git a/src/main/java/com/juick/server/api/Messages.java b/src/main/java/com/juick/server/api/Messages.java
index 8aae0d57..4ce1ea13 100644
--- a/src/main/java/com/juick/server/api/Messages.java
+++ b/src/main/java/com/juick/server/api/Messages.java
@@ -78,7 +78,7 @@ public class Messages {
int vuid = visitor.getUid();
List<Integer> mids = messagesService.getMyFeed(vuid, before_mid, true);
List<Message> msgs = messagesService.getMessages(visitor, mids);
- msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarPublicUrl(m.getUser())));
+ msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
return ResponseEntity.ok(msgs);
}
return FORBIDDEN;
@@ -141,7 +141,7 @@ public class Messages {
}
}
List<Message> msgs = messagesService.getMessages(visitor, mids);
- msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarPublicUrl(m.getUser())));
+ msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
return ResponseEntity.ok(msgs);
}
@DeleteMapping("/api/messages")
@@ -161,7 +161,7 @@ public class Messages {
public List<Message> getDiscussions(
@RequestParam(required = false, defaultValue = "0") Long to) {
List<Message> msgs = messagesService.getMessages(UserUtils.getCurrentUser(), messagesService.getDiscussions(UserUtils.getCurrentUser().getUid(), to));
- msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarPublicUrl(m.getUser())));
+ msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
return msgs;
}
@GetMapping("/api/thread")
@@ -177,10 +177,10 @@ public class Messages {
if (userService.getUserByName(msg.getUser().getName()).isBanned()) {
throw new HttpNotFoundException();
}
- msg.getUser().setAvatar(webApp.getAvatarPublicUrl(msg.getUser()));
+ msg.getUser().setAvatar(webApp.getAvatarWebPath(msg.getUser()));
msg.setRecommendations(new HashSet<>(messagesService.getMessageRecommendations(msg.getMid())));
List<com.juick.Message> replies = messagesService.getReplies(visitor, mid);
- replies.forEach(m -> m.getUser().setAvatar(webApp.getAvatarPublicUrl(m.getUser())));
+ replies.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
if (!visitor.isAnonymous()) {
userService.updateLastSeen(visitor);
applicationEventPublisher.publishEvent(
diff --git a/src/main/java/com/juick/server/api/PM.java b/src/main/java/com/juick/server/api/PM.java
index e00a4c97..05f46d8d 100644
--- a/src/main/java/com/juick/server/api/PM.java
+++ b/src/main/java/com/juick/server/api/PM.java
@@ -69,7 +69,7 @@ public class PM {
}
List<Message> msgs = pmQueriesService.getPMMessages(visitor.getUid(), uid);
- msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarPublicUrl(m.getUser())));
+ msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
return msgs;
}
@@ -115,7 +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)));
+ lastconv.forEach(c -> c.setAvatar(webApp.getAvatarWebPath(c)));
PrivateChats pms = new PrivateChats();
pms.setUsers(lastconv);
return pms;
diff --git a/src/main/java/com/juick/server/api/Users.java b/src/main/java/com/juick/server/api/Users.java
index 791071a5..c1cee8b5 100644
--- a/src/main/java/com/juick/server/api/Users.java
+++ b/src/main/java/com/juick/server/api/Users.java
@@ -69,12 +69,12 @@ public class Users {
if (!unames.isEmpty() && unames.size() < 20)
users.addAll(userService.getUsersByName(unames));
}
- users.forEach(u -> u.setAvatar(webApp.getAvatarPublicUrl(u)));
+ users.forEach(u -> u.setAvatar(webApp.getAvatarWebPath(u)));
if (!users.isEmpty())
return users;
if (!UserUtils.getCurrentUser().isAnonymous()) {
User visitor = UserUtils.getCurrentUser();
- visitor.setAvatar(webApp.getAvatarPublicUrl(visitor));
+ visitor.setAvatar(webApp.getAvatarWebPath(visitor));
return Collections.singletonList(visitor);
}
@@ -93,7 +93,7 @@ public class Users {
me.setUnreadCount(unread.size());
me.setRead(userService.getUserFriends(visitor.getUid()));
me.setReaders(userService.getUserReaders(visitor.getUid()));
- me.setAvatar(webApp.getAvatarPublicUrl(visitor));
+ me.setAvatar(webApp.getAvatarWebPath(visitor));
return me;
}
@@ -118,7 +118,7 @@ public class Users {
if (uid > 0) {
List<User> friends = userService.getUserFriends(uid);
- friends.forEach(f -> f.setAvatar(webApp.getAvatarPublicUrl(f)));
+ friends.forEach(f -> f.setAvatar(webApp.getAvatarWebPath(f)));
return friends;
}
throw new HttpNotFoundException();
@@ -145,7 +145,7 @@ public class Users {
if (uid > 0) {
List<User> readers = userService.getUserReaders(uid);
- readers.forEach(r -> r.setAvatar(webApp.getAvatarPublicUrl(r)));
+ readers.forEach(r -> r.setAvatar(webApp.getAvatarWebPath(r)));
return readers;
}
throw new HttpNotFoundException();
@@ -155,7 +155,7 @@ public class Users {
public UserInfo getUserInfo(@PathVariable String uname) {
User user = userService.getUserByName(uname);
if (!user.isBanned()) {
- user.setAvatar(webApp.getAvatarPublicUrl(user));
+ user.setAvatar(webApp.getAvatarWebPath(user));
return userService.getUserInfo(user);
}
throw new HttpNotFoundException();
diff --git a/src/main/java/com/juick/server/api/activity/Profile.java b/src/main/java/com/juick/server/api/activity/Profile.java
index 60e099d0..979f6265 100644
--- a/src/main/java/com/juick/server/api/activity/Profile.java
+++ b/src/main/java/com/juick/server/api/activity/Profile.java
@@ -104,7 +104,7 @@ public class Profile {
person.setFollowers(activityPubManager.followersUri(user));
person.setFollowing(activityPubManager.followingUri(user));
UriComponentsBuilder image = UriComponentsBuilder.fromUriString(baseImagesUri);
- image.path(webApp.getAvatarPublicUrl(user));
+ image.path(webApp.getAvatarWebPath(user));
Image avatar = new Image();
avatar.setUrl(image.toUriString());
avatar.setMediaType("image/png");
diff --git a/src/main/java/com/juick/server/api/rss/MessagesView.java b/src/main/java/com/juick/server/api/rss/MessagesView.java
index 4b29108e..2dd9f53b 100644
--- a/src/main/java/com/juick/server/api/rss/MessagesView.java
+++ b/src/main/java/com/juick/server/api/rss/MessagesView.java
@@ -87,7 +87,7 @@ public class MessagesView extends AbstractRssFeedView {
String link = String.format("http://juick.com/%s/", user.getName());
feed.setLink(link);
Image rssImage = new Image();
- rssImage.setUrl(webApp.getAvatarPublicUrl(user));
+ rssImage.setUrl(webApp.getAvatarWebPath(user));
rssImage.setTitle(title);
rssImage.setLink(link);
feed.setImage(rssImage);
diff --git a/src/main/java/com/juick/server/www/WebApp.java b/src/main/java/com/juick/server/www/WebApp.java
index 3ab09de2..08c6188d 100644
--- a/src/main/java/com/juick/server/www/WebApp.java
+++ b/src/main/java/com/juick/server/www/WebApp.java
@@ -79,8 +79,4 @@ public class WebApp {
}
return resourceUrlProvider.getForLookupPath("/av-96.png");
}
- public String getAvatarPublicUrl(User user) {
- UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseImagesUri);
- return uri.replacePath(getAvatarWebPath(user)).toUriString();
- }
}
diff --git a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
index ba8e7b66..ad988bcb 100644
--- a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
+++ b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
@@ -551,7 +551,7 @@ public class MessagesWWW {
headers += "<meta property=\"og:image\" content=\"" + msgImage + "\" />";
}
} else {
- String msgImage = webApp.getAvatarPublicUrl(msg.getUser());
+ String msgImage = webApp.getAvatarWebPath(msg.getUser());
headers += "<meta property=\"og:image\" content=\"" + msgImage + "\" />";
}
model.addAttribute("ogtype", "article");