chatwoot admin panel fixes
All checks were successful
Deploy to VPS / deploy (push) Successful in 1m19s
All checks were successful
Deploy to VPS / deploy (push) Successful in 1m19s
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.honey.honey.controller;
|
||||
|
||||
import com.honey.honey.dto.*;
|
||||
import com.honey.honey.model.UserA;
|
||||
import com.honey.honey.service.AdminUserService;
|
||||
import com.honey.honey.service.UserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -33,6 +35,7 @@ public class AdminUserController {
|
||||
private static final Set<String> WITHDRAWAL_SORT_FIELDS = Set.of("id", "usdAmount", "cryptoName", "amountToSend", "txhash", "status", "paymentId", "createdAt", "resolvedAt");
|
||||
|
||||
private final AdminUserService adminUserService;
|
||||
private final UserService userService;
|
||||
|
||||
private boolean isGameAdmin() {
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
@@ -115,8 +118,24 @@ public class AdminUserController {
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve Honey user ID from Telegram user ID.
|
||||
* Used by the Chatwoot embed when the contact has no honey_user_id set:
|
||||
* Chatwoot (Telegram channel) often uses Telegram user ID as contact identifier.
|
||||
*/
|
||||
@GetMapping("/by-telegram-id")
|
||||
@PreAuthorize("hasAnyRole('ADMIN', 'GAME_ADMIN', 'TICKETS_SUPPORT')")
|
||||
public ResponseEntity<Map<String, Integer>> getUserByTelegramId(@RequestParam("telegram_id") Long telegramId) {
|
||||
if (telegramId == null) {
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
return userService.getUserByTelegramId(telegramId)
|
||||
.map(user -> ResponseEntity.ok(Map.of("id", user.getId())))
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN', 'GAME_ADMIN')")
|
||||
@PreAuthorize("hasAnyRole('ADMIN', 'GAME_ADMIN', 'TICKETS_SUPPORT')")
|
||||
public ResponseEntity<AdminUserDetailDto> getUserDetail(@PathVariable Integer id) {
|
||||
AdminUserDetailDto userDetail = adminUserService.getUserDetail(id, isGameAdmin());
|
||||
if (userDetail == null) {
|
||||
|
||||
Reference in New Issue
Block a user