diff options
author | Vitaly Takmazov | 2018-11-20 19:07:59 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-11-20 19:07:59 +0300 |
commit | b6bb0dc8a3391442fad0124baa12799982cd6d8d (patch) | |
tree | 664a6bdbc76cbc2219eb4c67f8aca875d83fccc0 /src/main/java/com/juick/server/www | |
parent | 6d4f8164ac97690a1993981605435cdc6ff097f2 (diff) |
fix api avatar urls
Diffstat (limited to 'src/main/java/com/juick/server/www')
-rw-r--r-- | src/main/java/com/juick/server/www/WebApp.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/www/WebApp.java b/src/main/java/com/juick/server/www/WebApp.java index 08c6188d..7282eeeb 100644 --- a/src/main/java/com/juick/server/www/WebApp.java +++ b/src/main/java/com/juick/server/www/WebApp.java @@ -25,6 +25,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.servlet.resource.ResourceUrlProvider; import org.springframework.web.util.UriComponentsBuilder; +import javax.annotation.PostConstruct; import javax.inject.Inject; import java.util.ArrayList; import java.util.Arrays; @@ -43,6 +44,12 @@ public class WebApp { private ResourceUrlProvider resourceUrlProvider; @Value("${img_url:http://localhost:8080/i/}") private String baseImagesUri; + UriComponentsBuilder avatarBuilder; + + @PostConstruct + public void init() { + avatarBuilder = UriComponentsBuilder.fromUriString(baseImagesUri); + } public List<Tag> parseTags(String tagsStr) { List<Tag> tags = new ArrayList<>(); @@ -79,4 +86,9 @@ public class WebApp { } return resourceUrlProvider.getForLookupPath("/av-96.png"); } + + public String getAvatarUrl(User user) { + avatarBuilder.replacePath(getAvatarWebPath(user)); + return avatarBuilder.build().toUriString(); + } } |