mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-18 19:54:26 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bfadda1e7d |
@@ -36,7 +36,6 @@ public class ReactionController {
|
|||||||
Authentication auth) {
|
Authentication auth) {
|
||||||
Reaction reaction = reactionService.reactToPost(auth.getName(), postId, req.getType());
|
Reaction reaction = reactionService.reactToPost(auth.getName(), postId, req.getType());
|
||||||
if (reaction == null) {
|
if (reaction == null) {
|
||||||
pointService.deductForReactionOfPost(auth.getName(), postId);
|
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
ReactionDto dto = reactionMapper.toDto(reaction);
|
ReactionDto dto = reactionMapper.toDto(reaction);
|
||||||
@@ -51,7 +50,6 @@ public class ReactionController {
|
|||||||
Authentication auth) {
|
Authentication auth) {
|
||||||
Reaction reaction = reactionService.reactToComment(auth.getName(), commentId, req.getType());
|
Reaction reaction = reactionService.reactToComment(auth.getName(), commentId, req.getType());
|
||||||
if (reaction == null) {
|
if (reaction == null) {
|
||||||
pointService.deductForReactionOfComment(auth.getName(), commentId);
|
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
ReactionDto dto = reactionMapper.toDto(reaction);
|
ReactionDto dto = reactionMapper.toDto(reaction);
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ public enum PointHistoryType {
|
|||||||
COMMENT,
|
COMMENT,
|
||||||
POST_LIKED,
|
POST_LIKED,
|
||||||
COMMENT_LIKED,
|
COMMENT_LIKED,
|
||||||
POST_LIKE_CANCELLED,
|
|
||||||
COMMENT_LIKE_CANCELLED,
|
|
||||||
INVITE,
|
INVITE,
|
||||||
FEATURE,
|
FEATURE,
|
||||||
SYSTEM_ONLINE,
|
SYSTEM_ONLINE,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.openisle.model.User;
|
|||||||
import com.openisle.model.Post;
|
import com.openisle.model.Post;
|
||||||
import com.openisle.model.Comment;
|
import com.openisle.model.Comment;
|
||||||
import com.openisle.model.NotificationType;
|
import com.openisle.model.NotificationType;
|
||||||
import com.openisle.model.ReactionType;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -30,8 +29,4 @@ public interface NotificationRepository extends JpaRepository<Notification, Long
|
|||||||
List<Notification> findByTypeAndFromUser(NotificationType type, User fromUser);
|
List<Notification> findByTypeAndFromUser(NotificationType type, User fromUser);
|
||||||
|
|
||||||
void deleteByTypeAndFromUserAndPost(NotificationType type, User fromUser, Post post);
|
void deleteByTypeAndFromUserAndPost(NotificationType type, User fromUser, Post post);
|
||||||
|
|
||||||
void deleteByTypeAndFromUserAndPostAndReactionType(NotificationType type, User fromUser, Post post, ReactionType reactionType);
|
|
||||||
|
|
||||||
void deleteByTypeAndFromUserAndCommentAndReactionType(NotificationType type, User fromUser, Comment comment, ReactionType reactionType);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,14 +114,6 @@ public class NotificationService {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteReactionNotification(User fromUser, Post post, Comment comment, ReactionType reactionType) {
|
|
||||||
if (post != null) {
|
|
||||||
notificationRepository.deleteByTypeAndFromUserAndPostAndReactionType(NotificationType.REACTION, fromUser, post, reactionType);
|
|
||||||
} else if (comment != null) {
|
|
||||||
notificationRepository.deleteByTypeAndFromUserAndCommentAndReactionType(NotificationType.REACTION, fromUser, comment, reactionType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create notifications for all admins when a user submits a register request.
|
* Create notifications for all admins when a user submits a register request.
|
||||||
* Old register request notifications from the same applicant are removed first.
|
* Old register request notifications from the same applicant are removed first.
|
||||||
|
|||||||
@@ -150,16 +150,6 @@ public class PointService {
|
|||||||
return addPoint(poster, 10, PointHistoryType.POST_LIKED, post, null, reactioner);
|
return addPoint(poster, 10, PointHistoryType.POST_LIKED, post, null, reactioner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deductForReactionOfPost(String reactionerName, Long postId) {
|
|
||||||
User poster = postRepository.findById(postId).orElseThrow().getAuthor();
|
|
||||||
User reactioner = userRepository.findByUsername(reactionerName).orElseThrow();
|
|
||||||
if (poster.getId().equals(reactioner.getId())) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Post post = postRepository.findById(postId).orElseThrow();
|
|
||||||
return addPoint(poster, -10, PointHistoryType.POST_LIKE_CANCELLED, post, null, reactioner);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 考虑点赞者和评论者是同一个的情况
|
// 考虑点赞者和评论者是同一个的情况
|
||||||
public int awardForReactionOfComment(String reactionerName, Long commentId) {
|
public int awardForReactionOfComment(String reactionerName, Long commentId) {
|
||||||
// 根据帖子id找到评论者
|
// 根据帖子id找到评论者
|
||||||
@@ -179,17 +169,6 @@ public class PointService {
|
|||||||
return addPoint(commenter, 10, PointHistoryType.COMMENT_LIKED, post, comment, reactioner);
|
return addPoint(commenter, 10, PointHistoryType.COMMENT_LIKED, post, comment, reactioner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int deductForReactionOfComment(String reactionerName, Long commentId) {
|
|
||||||
User commenter = commentRepository.findById(commentId).orElseThrow().getAuthor();
|
|
||||||
User reactioner = userRepository.findByUsername(reactionerName).orElseThrow();
|
|
||||||
if (commenter.getId().equals(reactioner.getId())) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Comment comment = commentRepository.findById(commentId).orElseThrow();
|
|
||||||
Post post = comment.getPost();
|
|
||||||
return addPoint(commenter, -10, PointHistoryType.COMMENT_LIKE_CANCELLED, post, comment, reactioner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public java.util.List<PointHistory> listHistory(String userName) {
|
public java.util.List<PointHistory> listHistory(String userName) {
|
||||||
User user = userRepository.findByUsername(userName).orElseThrow();
|
User user = userRepository.findByUsername(userName).orElseThrow();
|
||||||
if (pointHistoryRepository.countByUser(user) == 0) {
|
if (pointHistoryRepository.countByUser(user) == 0) {
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ public class ReactionService {
|
|||||||
java.util.Optional<Reaction> existing =
|
java.util.Optional<Reaction> existing =
|
||||||
reactionRepository.findByUserAndPostAndType(user, post, type);
|
reactionRepository.findByUserAndPostAndType(user, post, type);
|
||||||
if (existing.isPresent()) {
|
if (existing.isPresent()) {
|
||||||
notificationService.deleteReactionNotification(user, post, null, type);
|
|
||||||
reactionRepository.delete(existing.get());
|
reactionRepository.delete(existing.get());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -66,7 +65,6 @@ public class ReactionService {
|
|||||||
java.util.Optional<Reaction> existing =
|
java.util.Optional<Reaction> existing =
|
||||||
reactionRepository.findByUserAndCommentAndType(user, comment, type);
|
reactionRepository.findByUserAndCommentAndType(user, comment, type);
|
||||||
if (existing.isPresent()) {
|
if (existing.isPresent()) {
|
||||||
notificationService.deleteReactionNotification(user, null, comment, type);
|
|
||||||
reactionRepository.delete(existing.get());
|
reactionRepository.delete(existing.get());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ function onError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.base-image.is-loaded {
|
.base-image.is-loaded {
|
||||||
filter: none;
|
/* Allow filters from parent classes (e.g. grayscale for unfinished medals) */
|
||||||
transform: none;
|
transform: none;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user