JujaLabs / juja-platform

0 stars 7 forks source link

Add 'Hide link' logic #55

Closed ivshapovalov closed 6 years ago

ivshapovalov commented 6 years ago
Task 'As a user I want to hide my link in the storage using link id'
Microservice - LINKS SLACK BOT
Subtask 'Add 'hide' link endpoint' from milestone
https://github.com/JujaLabs/juja-platform/milestones/2

1) What is this feature/fix provided for?
    User want to hide his link by id using slack slash command '/links-hide'
    This command send POST request to our bot microservice on url '/v1/commands/links/hide'
    Bot microservice handle it, define user uuid (using Users microservice) and send request to Links microservice
    to hide users link. 
    Links microservice returns JSON with hidden Link entity or Exception message. 
    Conntoller send to slack Message: 'Thanks, Link '...' hide!' or Exception message, returns from Links microservice 

2) List the objects you want to add or change, use appropriate API annotations
    Model:
              Add class HideLinkRequest
               public class HideLinkRequest
                          private final String owner
                          private final String id

             Update class Link
              private final String owner

    Controller:
        Add method 
            @ApiOperation(value = "Hide user's link", notes = "Returns a message with hiddenLink id or Exception message", response = RichMessage.class, tags = {})
            @ApiResponses(value = {
                    @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Successfully archive new link"),
                    @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = "Bad request"),
                    @ApiResponse(code = HttpURLConnection.HTTP_BAD_METHOD, message = "Bad method"),
                    @ApiResponse(code = HttpURLConnection.HTTP_UNSUPPORTED_TYPE, message = "Unsupported request media type")
            })
            @PostMapping(value = "/links/hide", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
            public void onReceiveSlashCommandArchiveLink(
                                                @RequestParam("token") String token,
                                                @RequestParam("text") String text,
                                                @RequestParam("user_id") String fromSlackUser,
                                                @RequestParam("response_url") String responseUrl,
                                                HttpServletResponse response) throws IOException {}

    Service:
        Add method Link hideLink(String fromSlackUser, String text);

    Repository:
        Add method Link hideLink(HideLinkRequest hideLinkRequest);

3) Are there any special requirements or constraints?
         Repository send RemoveLinkRequest in PUT HTTP request (using Feign client) to Links service ('/v1/links' endpont).

4) What behavior do you expect? Any examples?
Benkoff commented 6 years ago

The task conflicts with actual code. ref #56