Skip to content

Commit

Permalink
fix : 카카오톡 미리보기 안되는 버그 해결 (CC-153) (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
putdata authored Aug 19, 2024
1 parent ecf5090 commit 9f74d92
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ jobs:
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}
sudo docker run -d -p 80:8080 ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}
sudo docker image prune -f
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public record ShareUrlRequestDto(
double distance,
int percentage
double percentage
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ShortUrlService {
@Transactional
public ShareUrlResponseDto shareUrl(ShareUrlRequestDto req) {
double distance = Math.round(req.distance() * 1e6) / 1e6; // 소수점 6자리까지만 반영
int percentage = req.percentage();
double percentage = Math.round(req.percentage() * 1e2) / 1e2;
if (distance > 400.0 || percentage > 100) throw new UrlException(ErrorCode.BAD_REQUEST);

String longUrl = "/api/url/preview?distance=" + distance + "&percentage=" + percentage;
Expand Down Expand Up @@ -96,12 +96,18 @@ public ResponseEntity<?> shortUrlToLongUrl(String shortUrl) {
*/
public ResponseEntity<?> previewUrl(ShareUrlRequestDto req) {
return ResponseEntity.status(200)
.header("Content-Type", "text/html; charset=utf-8")
.body(
"<head>" +
"<meta property=\"og:title\" content=\"레이싱 게임\">" +
"<meta property=\"og:description\" content=\"이동 거리 " + req.distance() + "KM / 상위 " + req.percentage() + "%\">" +
"</head>" +
"<body><script>location.href=\"http://www.caecae.kro.kr/\";</script></body>"
"<html>" +
"<head>" +
"<meta charset=\"utf-8\">" +
"<meta property=\"og:type\" content=\"website\" />" +
"<meta property=\"og:title\" content=\"레이싱 게임\">" +
"<meta property=\"og:image\" content=\"https://contents-cdn.viewus.co.kr/image/2024/07/CP-2023-0096/image-b868c07a-8a04-44cc-9f07-a591905a3680.jpeg\">" +
"<meta property=\"og:description\" content=\"이동 거리 " + req.distance() + "KM / 상위 " + req.percentage() + "%\">" +
"</head>" +
"<body><script>location.href=\"http://www.caecae.kro.kr/racecasper\";</script></body>" +
"</html>"
);
}
}

0 comments on commit 9f74d92

Please sign in to comment.