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

채팅 입력 글자수 제한 #363

Merged
merged 6 commits into from
Sep 14, 2023
Merged

Conversation

withSang
Copy link
Member

@withSang withSang commented Sep 13, 2023

Summary

It fixes #242, fixes #228

  1. 아래 이벤트들에 대해 string 길이 검증(min: 1, max: 255)을 적용했습니다. (backend min(1) validation이 잘 안됨 #242)

    • chat.send
    • admin.agenda.create
    • agenda.template.create
    • user.tag.create
  2. 채팅 입력 창에 최대 글자 수(500자)와 최대 높이(30%)를 설정하고, 줄이 길어지는 경우 스크롤을 추가했습니다. ([채팅] 글이 아주 길어서 입력창이 채팅창을 가득 채우는 경우 스크롤 불가 & 채팅에 입력이 안됨 #228)

    • 크로미엄 브라우저에서 보이는 스크롤바
      • image
    • 파이어폭스 브라우저에서 보이는 스크롤바 (::-webkit-scrollbar css 의사 요소은 크로미엄만 지원)
      • (스크롤바에 커서를 두지 않았을 때)
        image
      • (스크롤바에 커서를 두었을 때)
        image

Further issues

@netlify
Copy link

netlify bot commented Sep 13, 2023

Deploy Preview for biseo-preview ready!

Name Link
🔨 Latest commit 39e9029
🔍 Latest deploy log https://app.netlify.com/sites/biseo-preview/deploys/650208e77c8be4000777ba79
😎 Deploy Preview https://deploy-preview-363--biseo-preview.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@withSang withSang self-assigned this Sep 13, 2023
@withSang withSang changed the title #242 backend min(1) validation이 잘 안됨, #228 & #309 채팅 입력 글자수 제한 채팅 입력 글자수 제한 Sep 13, 2023
@withSang withSang marked this pull request as ready for review September 13, 2023 18:53
const validated = useMemo(() => input.value.trim().length > 0, [input.value]);

/** @constant 클라이언트와 서버에서 사용하는 채팅 메시지의 최대 길이를 지정합니다. */
const maxMessageLength = 500;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서버, 클라이언트에서 모두 사용하는 값이라서 interface에 저장할 수 있으면 좋겠다고 생각했습니다!

const textAreaScrollStyle = css`
${scroll.y}
${scrollBar}
overflow-y: scroll;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overflow: scroll 대신 overflow: auto를 사용하면 스크롤바가 보일 때와 보이지 않을 때 텍스트 영역의 너비가 달라집니다.

@@ -7,7 +7,7 @@ import { Message } from "./common";
* description
*/
export const Send = z.object({
message: z.string().min(1),
message: z.string().min(1).max(500),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클라이언트가 채팅을 보내는 이벤트에서는 이 chat.Send 스키마에 따라 입력값 검증이 이루어집니다.

content: z.string().min(1),
resolution: z.string().min(1),
choices: z.array(z.string().min(1)).min(1),
title: z.string().min(1).max(255),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mysql에서 string 자료형의 길이는 [0, 255]입니다.
https://dev.mysql.com/doc/refman/8.0/en/string-type-syntax.html

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그래서 max 255였군용

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 처음 알았어요!

Copy link
Contributor

@babycroc babycroc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요! 코멘트도 친절하게 달아주다니 조아

Comment on lines +23 to +27
templateName: z.string().min(1).max(255),
title: z.string().min(1).max(255),
content: z.string().min(1).max(255),
resolution: z.string().min(1).max(255),
choices: z.array(z.string().min(1).max(255)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

옹 이제 템플릿이랑 유저태그 만드는 모달 쪽 프론트 로직에도 요거 검증이 들어가야겠네
관련 이슈 없으면 만들어줄 수 있나요??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우와 추가했습니다! 감사합니다!
#375

Copy link
Collaborator

@minjoo0729 minjoo0729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오왕 완전 수고하셨습니다!!
코멘트까지 상세하게 달아주셔서 감사해요 :)

content: z.string().min(1),
resolution: z.string().min(1),
choices: z.array(z.string().min(1)).min(1),
title: z.string().min(1).max(255),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그래서 max 255였군용

@withSang withSang merged commit 2263c18 into main Sep 14, 2023
@withSang withSang deleted the bug/backend-string-validation branch September 14, 2023 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants