added advertising
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.krylov.refound.controller;
|
||||
|
||||
import com.krylov.refound.dto.*;
|
||||
import com.krylov.refound.dto.ChatDto;
|
||||
import com.krylov.refound.dto.MessageDto;
|
||||
import com.krylov.refound.service.ChatService;
|
||||
import com.krylov.refound.service.UserService;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -10,9 +12,13 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -61,10 +67,13 @@ public class ChatController {
|
||||
chatService.markAsRead(chatId, currentUserId);
|
||||
}
|
||||
|
||||
private Long extractUserId(Authentication auth) {
|
||||
// Подставь свою логику получения userId из JWT/Authentication
|
||||
String login = auth.getName();
|
||||
log.debug("extractUserId by login {}", login);
|
||||
private Long extractUserId(Authentication authentication) {
|
||||
if (authentication == null || !authentication.isAuthenticated() || "anonymousUser".equals(authentication.getPrincipal())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String login = authentication.getName();
|
||||
log.info("extractUserId by login {}", login);
|
||||
return userService.getUserIdByLogin(login);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user