Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LH-201] SendbirdProfileUrl 버그 수정 (#43) #51

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -8,6 +8,7 @@
import com.lighthouse.lingoswap.auth.entity.Role;
import com.lighthouse.lingoswap.common.dto.ResponseDto;
import com.lighthouse.lingoswap.infra.dto.SendbirdCreateUserRequest;
import com.lighthouse.lingoswap.infra.service.DistributionService;
import com.lighthouse.lingoswap.infra.service.SendbirdService;
import com.lighthouse.lingoswap.member.dto.PreferredInterestsInfo;
import com.lighthouse.lingoswap.member.dto.UsedLanguageInfo;
Expand All @@ -34,6 +35,7 @@ public class AuthManager {
private final PreferredCountryService preferredCountryService;
private final PreferredInterestsService preferredInterestsService;
private final SendbirdService sendbirdService;
private final DistributionService distributionService;

@Transactional
public ResponseDto<LoginResponse> login(final String idToken) {
Expand Down Expand Up @@ -66,7 +68,7 @@ public ResponseDto<LoginResponse> signup(final String idToken, final MemberCreat
saveUsedLanguages(member, memberCreateRequest.usedLanguages());
savePreferredInterests(member, memberCreateRequest.preferredInterests());

SendbirdCreateUserRequest sendbirdCreateUserRequest = new SendbirdCreateUserRequest(authDetails.getUuid(), member.getName(), member.getProfileImageUri());
SendbirdCreateUserRequest sendbirdCreateUserRequest = new SendbirdCreateUserRequest(authDetails.getUuid(), member.getName(), distributionService.generateUri(member.getProfileImageUri()));
sendbirdService.createUser(sendbirdCreateUserRequest);

TokenPairDetails tokenPairDetails = tokenPairService.generateTokenPairDetailsByUsername(email);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.lighthouse.lingoswap.infra.dto;

public record SendbirdUpdateUserProfileUrlRequest(String profile_url) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.lighthouse.lingoswap.common.entity.SendbirdCreateChatroomResponse;
import com.lighthouse.lingoswap.infra.dto.SendbirdCreateChatRoomRequest;
import com.lighthouse.lingoswap.infra.dto.SendbirdCreateUserRequest;
import com.lighthouse.lingoswap.infra.dto.SendbirdUpdateUserProfileUrlRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
Expand Down Expand Up @@ -44,6 +45,15 @@ public SendbirdCreateChatroomResponse createChatRoom(final SendbirdCreateChatRoo
return restTemplate.postForEntity(apiUrl + "/group_channels", entity, SendbirdCreateChatroomResponse.class).getBody();
}

public void updateUserProfileUrl(final String uuid, final SendbirdUpdateUserProfileUrlRequest sendbirdUpdateUserProfileUrlRequest) {
webClient.put()
.uri("/users/" + uuid)
.bodyValue(sendbirdUpdateUserProfileUrlRequest)
.retrieve()
.bodyToMono(String.class)
.block();
}

public void deleteUser(final String uuid) {
webClient.delete()
.uri("/users/" + uuid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.lighthouse.lingoswap.common.dto.ResponseDto;
import com.lighthouse.lingoswap.common.service.MessageSourceService;
import com.lighthouse.lingoswap.infra.dto.SendbirdUpdateUserProfileUrlRequest;
import com.lighthouse.lingoswap.infra.service.DistributionService;
import com.lighthouse.lingoswap.infra.service.S3Service;
import com.lighthouse.lingoswap.infra.service.SendbirdService;
import com.lighthouse.lingoswap.member.dto.*;
import com.lighthouse.lingoswap.member.entity.*;
import com.lighthouse.lingoswap.question.dto.MyQuestionDetail;
Expand Down Expand Up @@ -38,6 +40,7 @@ public class MemberManager {
private final MessageSourceService messageSourceService;
private final CategoryService categoryService;
private final QuestionService questionService;
private final SendbirdService sendbirdService;

@Value("${aws.s3.bucket-name}")
private String bucketName;
Expand Down Expand Up @@ -204,8 +207,13 @@ public ResponseDto<LanguageFormResponse> readLanguageForm() {
return ResponseDto.success(new LanguageFormResponse(dto));
}

@Transactional
public ResponseDto<Object> patch(final String uuid, final MemberUpdateProfileRequest memberUpdateProfileRequest) {
Member member = memberService.findByUuid(uuid);
if (!member.getProfileImageUri().equals(memberUpdateProfileRequest.profileImageUri())) {
SendbirdUpdateUserProfileUrlRequest sendbirdUpdateUserProfileUrlRequest = new SendbirdUpdateUserProfileUrlRequest(distributionService.generateUri(member.getProfileImageUri()));
sendbirdService.updateUserProfileUrl(uuid, sendbirdUpdateUserProfileUrlRequest);
}
member.updateMember(memberUpdateProfileRequest.description(), memberUpdateProfileRequest.profileImageUri());
memberService.save(member);
return ResponseDto.success(null);
Expand Down