diff options
Diffstat (limited to 'src/main/java/com/juick/server/api')
5 files changed, 9 insertions, 28 deletions
diff --git a/src/main/java/com/juick/server/api/ApiSocialLogin.java b/src/main/java/com/juick/server/api/ApiSocialLogin.java index 2d0a5c7e..efbb56f4 100644 --- a/src/main/java/com/juick/server/api/ApiSocialLogin.java +++ b/src/main/java/com/juick/server/api/ApiSocialLogin.java @@ -79,7 +79,6 @@ public class ApiSocialLogin { private static final String TWITTER_VERIFY_URL = "https://api.twitter.com/1.1/account/verify_credentials.json"; @Inject private ObjectMapper jsonMapper; - private ServiceBuilder facebookBuilder, twitterBuilder, vkBuilder; private OAuth20Service facebookAuthService, vkAuthService; @Value("${twitter_consumer_key:appid}") @@ -110,9 +109,9 @@ public class ApiSocialLogin { @PostConstruct public void init() { - facebookBuilder = new ServiceBuilder(FACEBOOK_APPID); - twitterBuilder = new ServiceBuilder(twitterConsumerKey); - vkBuilder = new ServiceBuilder(VK_APPID); + ServiceBuilder facebookBuilder = new ServiceBuilder(FACEBOOK_APPID); + ServiceBuilder twitterBuilder = new ServiceBuilder(twitterConsumerKey); + ServiceBuilder vkBuilder = new ServiceBuilder(VK_APPID); verifier = new GoogleIdTokenVerifier.Builder(transport, jsonFactory) .setAudience(Collections.singletonList(googleClientId)) .build(); @@ -260,7 +259,7 @@ public class ApiSocialLogin { throw new HttpBadRequestException(); } - Long vkID = NumberUtils.toLong(jsonUser.getId(), 0); + long vkID = NumberUtils.toLong(jsonUser.getId(), 0); int uid = crosspostService.getUIDbyVKID(vkID); if (uid > 0) { UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(redirectUrl); diff --git a/src/main/java/com/juick/server/api/Notifications.java b/src/main/java/com/juick/server/api/Notifications.java index 72988298..e7eada2a 100644 --- a/src/main/java/com/juick/server/api/Notifications.java +++ b/src/main/java/com/juick/server/api/Notifications.java @@ -41,7 +41,6 @@ import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; import javax.inject.Inject; -import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -175,7 +174,7 @@ public class Notifications { @RequestMapping(value = "/api/notifications", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public Status doPut( @Visitor User visitor, - @RequestBody List<ExternalToken> list) throws IOException { + @RequestBody List<ExternalToken> list) { list.forEach(t -> { switch (t.getType()) { case "gcm": diff --git a/src/main/java/com/juick/server/api/Post.java b/src/main/java/com/juick/server/api/Post.java index 59bd05a7..255b7290 100644 --- a/src/main/java/com/juick/server/api/Post.java +++ b/src/main/java/com/juick/server/api/Post.java @@ -28,7 +28,6 @@ import com.juick.server.util.HttpForbiddenException; import com.juick.server.util.HttpNotFoundException; import com.juick.server.util.HttpUtils; import com.juick.service.MessagesService; -import com.juick.service.SubscriptionService; import com.juick.service.UserService; import com.juick.service.security.annotation.Visitor; import org.apache.commons.lang3.StringUtils; @@ -58,12 +57,8 @@ public class Post { private UserService userService; @Inject private MessagesService messagesService; - @Inject - private SubscriptionService subscriptionService; @Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}") private String tmpDir; - @Value("${img_path:#{systemEnvironment['TEMP'] ?: '/tmp'}}") - private String imgDir; @Inject CommandsManager commandsManager; @@ -155,7 +150,7 @@ public class Post { @ResponseStatus(value = HttpStatus.OK) public Status doPostRecomm(@Visitor User visitor, @RequestParam Integer mid) throws Exception { Optional<com.juick.Message> message = messagesService.getMessage(mid); - if (!message.isPresent()) { + if (message.isEmpty()) { throw new HttpNotFoundException(); } Message msg = message.get(); @@ -172,7 +167,7 @@ public class Post { public Status doPostSubscribe(@Visitor User visitor, @RequestParam Integer mid) throws Exception { Optional<com.juick.Message> message = messagesService.getMessage(mid); - if (!message.isPresent()) { + if (message.isEmpty()) { throw new HttpNotFoundException(); } Message msg = message.get(); @@ -199,7 +194,7 @@ public class Post { logger.info("got reaction with type: {}", reactionId); Optional<com.juick.Message> message = messagesService.getMessage(mid); - if (!message.isPresent()) { + if (message.isEmpty()) { throw new HttpNotFoundException(); } Message msg = message.get(); diff --git a/src/main/java/com/juick/server/api/Users.java b/src/main/java/com/juick/server/api/Users.java index 6d7c7a45..d5c1b5d7 100644 --- a/src/main/java/com/juick/server/api/Users.java +++ b/src/main/java/com/juick/server/api/Users.java @@ -28,33 +28,22 @@ import com.juick.server.util.WebUtils; import com.juick.server.www.WebApp; import com.juick.service.*; import com.juick.service.security.annotation.Visitor; -import com.juick.service.security.entities.JuickUser; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.inject.Inject; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static org.springframework.http.ResponseEntity.ok; -import static org.springframework.http.ResponseEntity.status; - /** * @author ugnich */ @@ -151,7 +140,7 @@ public class Users { "If you don't know, what this mean - just ignore this mail.\n", authCode), StringUtils.EMPTY, Collections.emptyMap())) { throw new HttpBadRequestException(); - }; + } } } } 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 88c76a93..a48958d2 100644 --- a/src/main/java/com/juick/server/api/activity/Profile.java +++ b/src/main/java/com/juick/server/api/activity/Profile.java @@ -23,7 +23,6 @@ import com.juick.server.api.activity.model.objects.Note; import com.juick.server.api.activity.model.objects.OrderedCollection; import com.juick.server.api.activity.model.objects.OrderedCollectionPage; import com.juick.server.api.activity.model.objects.Person; -import com.juick.server.util.HttpBadRequestException; import com.juick.server.util.HttpNotFoundException; import com.juick.server.www.WebApp; import com.juick.service.MessagesService; |