A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
895 B

package org.ros.chatto.service;
import java.util.List;
import java.util.Optional;
import com.spencerwi.either.Result;
import org.ros.chatto.dto.AdminUserDTO;
import org.ros.chatto.model.ChatUser;
import org.ros.chatto.repository.UserRepository;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Service
@RequiredArgsConstructor
@Slf4j
public class AdminService {
private final UserRepository userRepository;
public List<AdminUserDTO> getOtherUsers(String principal) {
return userRepository.getOtherUsers(principal);
}
public Result<Void> deleteUser(String userName) {
Optional<ChatUser> user = userRepository.findByUserName(userName);
return Result.attempt(() -> user.get()).map((u) -> {
userRepository.delete(u);
return (Void) null;
});
}
}