Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
246c49a
fix: 홈 조회 시 공지사항 응답에 content -> title 변경
hyunn522 Apr 3, 2025
cce1069
fix: 홈 조회 시 구독게시판 응답에 boradTitle -> postTiitle 네이밍 변경
hyunn522 Apr 3, 2025
fc28f2c
Merge pull request #440 from KUIT-Space/hotfix/add-title-to-notice-su…
hyunn522 Apr 3, 2025
cac71ae
[feat] add post title validation condition
drbug2000 Apr 3, 2025
84c17aa
[feat] delete @everyone in title
drbug2000 Apr 3, 2025
e13168a
fix: tagId로 조회하도록 수정
hyunn522 Apr 3, 2025
a253e4d
fix: 태그 조회 시 여러 개 조회 및 단건 조회 메소드 수정
hyunn522 Apr 3, 2025
26efbea
fix: postTitle 및 tagName 올바르게 초기화
hyunn522 Apr 3, 2025
7881596
fix: 태그 아이디로 게시물 조회 시 postTag와 조인
hyunn522 Apr 3, 2025
179627b
refactor: 구독한 게시판의 태그 아이디 포함
hyunn522 Apr 3, 2025
a632c9d
Merge pull request #444 from KUIT-Space/fix/#443/태그-조회-수정
hyunn522 Apr 4, 2025
a3e5f02
[fix] use delete mention every one
drbug2000 Apr 4, 2025
3d79c65
Merge pull request #442 from KUIT-Space/fix/#439/discord-post-title-c…
drbug2000 Apr 4, 2025
e82287e
Merge pull request #441 from KUIT-Space/develop
drbug2000 Apr 4, 2025
7711a15
[fix] discord edit comment fix
drbug2000 Apr 11, 2025
5fd427b
Merge pull request #446 from KUIT-Space/fix/#445/comment-dfit-error-i…
drbug2000 Apr 11, 2025
3dadcbe
refactor : 게시글 상세조회 api response에 isPostOwner 정보 추가
seongjunnoh Apr 15, 2025
05154ae
refactor : 게시글 리스트 조회 api response에 isPostOwner 추가
seongjunnoh Apr 15, 2025
5778e0f
Merge pull request #448 from KUIT-Space/refactor/#447/게시글-상세-조회-respo…
seongjunnoh Apr 16, 2025
0800937
Merge pull request #449 from KUIT-Space/develop
seongjunnoh Apr 16, 2025
a6d359a
feat: 홈 조회 응답 dto에 공지사항 게시판 아이디 추가
hyunn522 Apr 27, 2025
cf26e76
Merge pull request #451 from KUIT-Space/feat/#450/홈-조회-응답에-공지사항-게시판-아…
hyunn522 Apr 27, 2025
7540dd1
Merge pull request #452 from KUIT-Space/develop
hyunn522 Apr 27, 2025
d730997
[bug] forum post delete
drbug2000 Apr 27, 2025
66693e2
Merge pull request #454 from KUIT-Space/buh]/#453/delete-forum-post
drbug2000 Apr 27, 2025
2e553a0
Merge pull request #455 from KUIT-Space/develop
drbug2000 Apr 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package space.space_spring.domain.discord.adapter.in.discord;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
import net.dv8tion.jda.api.events.message.MessageUpdateEvent;
Expand All @@ -18,6 +19,7 @@
import java.util.Optional;
@Component
@RequiredArgsConstructor
@Slf4j
public class MessageUpdateEventListener extends ListenerAdapter {
private final DiscordUtil discordUtil;
private final LoadBoardCachePort loadBoardCachePort;
Expand Down Expand Up @@ -48,7 +50,7 @@ public void onMessageUpdate(MessageUpdateEvent event){
//log.info("not in cache. ignore");
return;
}

//log.info("edit message discord id:"+event.getMessageId().toString());
if(isComment(event)){
//Todo map comment update command
//Todo update comment UseCase call
Expand All @@ -57,6 +59,7 @@ public void onMessageUpdate(MessageUpdateEvent event){
.content(event.getMessage().getContentRaw())
.build();
updateCommentUseCase.updateCommentFromDiscord(command);
return;
}

//Todo map post update command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,17 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
return;
}

if (msg.getContentRaw().equals("!forumping")) {
if (msg.getContentRaw().startsWith("!forumping:")) {
Long channelId = Long.parseLong(msg.getContentRaw().split(":")[1]);
if(!discordUtil.isForumChannel(channelId)){
event.getMessage().reply("is not forum channel").queue();
System.out.println("is not forum channel");
return ;
}
CreateDiscordThreadCommand command = CreateDiscordThreadCommand.builder()
.channelDiscordId(1326507142286544957L)
.channelDiscordId(channelId)
.guildDiscordId(event.getGuild().getIdLong())
.webHookUrl("https://discordapp.com/api/webhooks/1341258654082404403/SnSx0qzymTEkwuEeVfXMPsUbSj_yiQ0tlCSOX4WOalSKBrdDlBXbz_TMFqnWIyIBy60m")
.webHookUrl(webHookPort.getOrCreate(event.getGuild().getForumChannelById(channelId).getIdLong()))
.contentMessage("spring server message test success\nhi\ncontent")
.avatarUrl(event.getMember().getEffectiveAvatarUrl())
.userName(event.getMember().getEffectiveName())
Expand Down Expand Up @@ -232,10 +238,19 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
String[] commands = msg.getContentRaw().split(":");
Long msgId = Long.parseLong(commands[1]);
Long originChannelId=discordUtil.getRootChannelId(event.getChannel());
deleteDiscordWebHookMessagePort.deleteInThread(webHookPort.getOrCreate(originChannelId),
deleteDiscordWebHookMessagePort.delete(webHookPort.getOrCreate(originChannelId),
event.getGuild().getIdLong()
,event.getChannel().getIdLong(),msgId);

}
if(msg.getContentRaw().startsWith("!deleteforum:")) {
String[] commands = msg.getContentRaw().split(":");
Long msgId = Long.parseLong(commands[1]);
Long originChannelId=discordUtil.getRootChannelId(event.getChannel());
deleteDiscordWebHookMessagePort.deleteThread(webHookPort.getOrCreate(originChannelId),
event.getGuild().getIdLong()
,event.getChannel().getIdLong(),msgId);

}
if(msg.getContentRaw().startsWith("!editcomment:")) {
String[] commands = msg.getContentRaw().split(":");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class TitleAndContentParser {
private String title;
private String content;
private static final String EVERYONE_MENTION = "@everyone";

private TitleAndContentParser(String title,String content){
this.title=title;
Expand All @@ -25,12 +26,12 @@ public static TitleAndContentParser parse(String input){
int index = 0;

// 첫 줄이 비어있으면 다음 줄로 이동
while (index < lines.length && lines[index].isBlank()) {
while (index < lines.length && !validateTitle(lines[index])) {
index++;
}

if (index < lines.length) {
title = lines[index]; // 첫 번째 유효한 줄을 title로 설정
title = deleteMention(lines[index]); // 첫 번째 유효한 줄을 title로 설정
index++;
}

Expand All @@ -40,5 +41,20 @@ public static TitleAndContentParser parse(String input){
return new TitleAndContentParser(title,content);
}

private static boolean validateTitle(String line){
if(line.isEmpty()||line.isBlank()){return false;}
if(line.trim().equalsIgnoreCase(EVERYONE_MENTION)){return false;}

return true;
}

private static String deleteMention(String input){
if(input==null){
return null;
}
if(input.contains(EVERYONE_MENTION)){
return input.replace(EVERYONE_MENTION, "");
}
return input;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.dv8tion.jda.api.entities.WebhookClient;
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
import org.springframework.stereotype.Component;
import space.space_spring.domain.discord.adapter.in.discord.DiscordUtil;
import space.space_spring.domain.discord.application.port.out.deleteWebHookMessage.DeleteDiscordWebHookMessagePort;
import space.space_spring.global.exception.CustomException;

Expand All @@ -20,16 +21,24 @@
@Slf4j
public class DeleteWebHookMessageAdapter implements DeleteDiscordWebHookMessagePort {
private final JDA jda;
private final DiscordUtil discordUtil;
@Override
public void delete(String webHook,Long guildDiscordId, Long channelDiscordId,Long messageId){
try {
if(discordUtil.isForumChannel(channelDiscordId)){
deleteThread(webHook,guildDiscordId,channelDiscordId,messageId);
return;
}
WebhookClient.createClient(jda, webHook).deleteMessageById(messageId).complete();
}catch(ErrorResponseException e){
if(e.getErrorCode()==10008){
throw new CustomException(NOT_PROVIDE_CROSS_DELETE);
}
}
}
public void deleteThread(String webHook,Long guildDiscordId, Long channelDiscordId,Long messageId){
jda.getThreadChannelById(messageId).delete().complete();
}

public void deleteInThread(String webHook,Long guildDiscordId, Long threadDiscordId,Long messageId){
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public interface DeleteDiscordWebHookMessagePort {
void delete(String webHook,Long guildDiscordId,Long channelDiscordId,Long messageId);
void deleteInThread(String webHook,Long guildDiscordId, Long threadDiscordId,Long messageId);
void deleteThread(String webHook,Long guildDiscordId,Long channelDiscordId,Long messageId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//import space.space_spring.domain.discord.application.port.out.CreateDiscordThreadPort;
import space.space_spring.domain.discord.application.port.out.CreateDiscordWebHookMessageCommand;
import space.space_spring.domain.discord.application.port.out.CreateDiscordWebHookMessagePort;
import space.space_spring.domain.post.application.port.in.Tag.LoadTagUseCase;
import space.space_spring.domain.post.application.port.out.LoadBoardPort;
import space.space_spring.domain.post.application.port.out.LoadTagPort;
import space.space_spring.domain.post.domain.AttachmentType;
Expand All @@ -21,7 +20,6 @@

import java.util.Comparator;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;

import static space.space_spring.global.common.response.status.BaseExceptionResponseStatus.BOARD_NOT_EXIST;
import static space.space_spring.global.common.response.status.BaseExceptionResponseStatus.DISCORD_THREAD_CREATE_FAIL;
Expand Down Expand Up @@ -83,7 +81,7 @@ private CreateDiscordWebHookMessageCommand mapToWebHookMessage(CreatePostInDisco
.map(attachment->attachment.getAttachmentUrl()).toList()
)
.discordTags(
loadTagPort.loadById(command.getTagIds()).stream().map(tag->tag.getDiscordId()).toList()
loadTagPort.loadAllByIds(command.getTagIds()).stream().map(tag->tag.getDiscordId()).toList()
)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
@AllArgsConstructor
public class NoticeSummary {

private Long boardId;

private Long postId;

private String content;
private String title;

private String timePassed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public class SubscriptionSummary {

private String boardName;

private String boardTitle;
private String postTitle;

private Long tagId;

private String tagName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public ReadHomeResult readHome(Long spaceMemberId, Long spaceId) {

for (Post post : noticePosts) {
notices.add(new NoticeSummary(
post.getBoardId(),
post.getId(),
post.getContent().getValue(),
post.getTitle(),
ConvertCreatedDate.setCreatedDate(post.getBaseInfo().getCreatedAt())
));
}
Expand All @@ -75,16 +76,17 @@ public ReadHomeResult readHome(Long spaceMemberId, Long spaceId) {
List<SubscriptionSummary> subscriptions = new ArrayList<>();
List<Subscription> subscribedBoards = loadSubscriptionPort.loadBySpaceMember(spaceMemberId);
for (Subscription subscription : subscribedBoards) {
Board board = loadBoardPort.loadById(subscription.getBoardId());
Optional<Tag> tag = loadTagPort.loadByBoardId(board.getId());

// 각 게시판에서 제일 최신 게시물 정보 가져오기
Optional<Post> latestPost;
String postTitle = "";
String tagName = "";
if (tag.isPresent()) {
tagName = tag.get().getTagName();
latestPost = loadPostPort.loadLatestPostByBoardIdAndTagId(board.getId(), tag.get().getId());

Board board = loadBoardPort.loadById(subscription.getBoardId());
Long tagId = subscription.getTagId();

if (tagId != null) {
Tag tag = loadTagPort.loadById(subscription.getTagId());
tagName = tag.getTagName();
latestPost = loadPostPort.loadLatestPostByBoardIdAndTagId(board.getId(), tag.getId());
if (latestPost.isPresent()) postTitle = latestPost.get().getTitle();
} else {
latestPost = loadPostPort.loadLatestPostsByBoardIds(List.of(board.getId()), 1)
Expand All @@ -93,7 +95,7 @@ public ReadHomeResult readHome(Long spaceMemberId, Long spaceId) {
if (latestPost.isPresent()) postTitle = latestPost.get().getTitle();
}

subscriptions.add(new SubscriptionSummary(board.getId(), board.getBoardName(), postTitle, tagName));
subscriptions.add(new SubscriptionSummary(board.getId(), board.getBoardName(), postTitle, tagId, tagName));
}
result.addSubscription(subscriptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ public class ResponseOfReadPostDetail {

private Boolean isLiked;

private Boolean isPostOwner;

private List<ResponseOfCommentDetail> responseOfCommentDetails;

@Builder
private ResponseOfReadPostDetail(String creatorName, String creatorProfileImageUrl, String createdAt, String lastModifiedAt,
String title, String content, List<String> attachmentUrls, int likeCount, Boolean isLiked,
List<ResponseOfCommentDetail> responseOfCommentDetails) {
Boolean isPostOwner, List<ResponseOfCommentDetail> responseOfCommentDetails) {
this.creatorName = creatorName;
this.creatorProfileImageUrl = creatorProfileImageUrl;
this.createdAt = createdAt;
Expand All @@ -42,6 +44,7 @@ private ResponseOfReadPostDetail(String creatorName, String creatorProfileImageU
this.attachmentUrls = attachmentUrls;
this.likeCount = likeCount;
this.isLiked = isLiked;
this.isPostOwner = isPostOwner;
this.responseOfCommentDetails = responseOfCommentDetails;
}

Expand All @@ -56,6 +59,7 @@ public static ResponseOfReadPostDetail of(ResultOfReadPostDetail result) {
.attachmentUrls(result.getAttachmentUrls())
.likeCount(result.getLikeCount())
.isLiked(result.getIsLiked())
.isPostOwner(result.getIsPostOwner())
.responseOfCommentDetails(
result.getInfoOfCommentDetails().stream()
.map(ResponseOfCommentDetail::of)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.web.bind.annotation.RestController;
import space.space_spring.domain.post.application.port.in.readPostList.ListOfPostSummary;
import space.space_spring.domain.post.application.port.in.readPostList.ReadPostListUseCase;
import space.space_spring.global.argumentResolver.jwtLogin.JwtLoginAuth;
import space.space_spring.global.common.response.BaseResponse;


Expand All @@ -29,13 +30,14 @@ public class ReadPostListController {
""")
@GetMapping("/space/{spaceId}/board/{boardId}/post")
public BaseResponse<ResponseOfReadPostList> readPostList(
@JwtLoginAuth Long spaceMemberId,
@PathVariable Long spaceId,
@PathVariable Long boardId,
@RequestParam(required = false) Long tagId,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "20") int size) {
Pageable pageable = PageRequest.of(page, size, Sort.by("postBase.createdAt").descending());
ListOfPostSummary postSummaries = readPostListUseCase.readPostList(boardId, tagId, pageable);
ListOfPostSummary postSummaries = readPostListUseCase.readPostList(spaceMemberId, boardId, tagId, pageable);
return new BaseResponse<>(ResponseOfReadPostList.of(postSummaries));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ public class ResponseOfPostSummary {

private String postImageUrl;

private ResponseOfPostSummary(Long postId, String title, String content, int likeCount, int commentCount, String createdAt, String creatorNickname, String postImageUrl){
private Boolean isPostOwner;

private ResponseOfPostSummary(Long postId, String title, String content, int likeCount, int commentCount,
String createdAt, String creatorNickname, String postImageUrl, Boolean isPostOwner){
this.postId = postId;
this.title = title;
this.content = content;
Expand All @@ -32,6 +35,7 @@ private ResponseOfPostSummary(Long postId, String title, String content, int lik
this.createdAt = createdAt;
this.creatorNickname = creatorNickname;
this.postImageUrl = postImageUrl;
this.isPostOwner = isPostOwner;
}

public static ResponseOfPostSummary of(PostSummary summaryOfPost) {
Expand All @@ -43,7 +47,8 @@ public static ResponseOfPostSummary of(PostSummary summaryOfPost) {
summaryOfPost.getCommentCount(),
ConvertCreatedDate.setCreatedDate(summaryOfPost.getCreatedAt()),
summaryOfPost.getCreatorNickname(),
summaryOfPost.getPostImageUrl()
summaryOfPost.getPostImageUrl(),
summaryOfPost.getIsPostOwner()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package space.space_spring.domain.post.adapter.out.persistence.post;

import com.querydsl.core.group.GroupBy;
import com.querydsl.core.types.Projections;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.jpa.JPAExpressions;
Expand Down Expand Up @@ -75,7 +74,12 @@ public PostDetailView loadPostDetail(Long postId, Long spaceMemberId) {
.and(postLike.spaceMember.id.eq(spaceMemberId))
.and(postLike.isLiked.eq(true))
.and(postLike.status.eq(BaseStatusType.ACTIVE)))
.exists()
.exists(),
// 스페이스 멤버가 해당 게시글 작성자인지
Expressions.booleanTemplate(
"CASE WHEN {0} = {1} THEN true ELSE false END",
postCreator.id,
spaceMemberId)
))
.from(post)
.leftJoin(post.postBase, postBase)
Expand Down Expand Up @@ -106,6 +110,7 @@ public PostDetailView loadPostDetail(Long postId, Long spaceMemberId) {
.attachmentUrls(attachmentUrls)
.likeCount(detail.getLikeCount())
.isLiked(detail.getIsLiked())
.isPostOwner(detail.getIsPostOwner())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public Optional<PostJpaEntity> findLatestByBoardIdAndTagId(Long boardId, Long ta
return Optional.ofNullable(jpaQueryFactory.selectFrom(postJpaEntity)
.join(postJpaEntity.postBase, postBaseJpaEntity)
.join(postBaseJpaEntity.board, boardJpaEntity)
.join(tagJpaEntity).on(tagJpaEntity.board.eq(boardJpaEntity))
.join(postTagJpaEntity).on(postTagJpaEntity.postBase.eq(postBaseJpaEntity))
.join(tagJpaEntity).on(postTagJpaEntity.tag.eq(tagJpaEntity))
.where(
boardJpaEntity.id.eq(boardId),
tagJpaEntity.id.eq(tagId),
Expand Down
Loading
Loading