storycraft / node-kakao

Loco protocol compatible library
MIT License
409 stars 115 forks source link

컴퓨터에선 멘션이 된걸로 표시되지만, 폰에선 멘션이 되지 않은것으로 표시됨 #148

Closed nunnu1028 closed 3 years ago

nunnu1028 commented 3 years ago

Describe the bug 컴퓨터에선 멘션이 된걸로 표시되지만, 폰에선 멘션이 되지 않은것으로 표시됨.

Used Code

    let builder = new ChatBuilder();
    builder.text("안녕하세요, ");
    builder.append(new MentionContent(user));

    channel.sendChat(builder.build(KnownChatType.TEXT));

Expected behavior 폰에서도 멘션이 된것으로 표시되어야함.

Screenshots image

(왼쪽이 컴퓨터, 오른쪽이 폰)

NodeKakao Version 4.0.0-rc.1

nunnu1028 commented 3 years ago

확인 결과 at이 null임.

nunnu1028 commented 3 years ago
        append(chat) {
            if (!chat.attachment)
                return;
            if (!chat.attachment['mentions'])
                chat.attachment['mentions'] = [];
            let lastAt = 0;
            for (let i = 0; i < chat.text.length; i++) if (chat.text[i] === "@") lastAt++;
            const mentions = chat.attachment['mentions'];
            let map = mentions.find((value) => this.user.userId.eq(value.user_id));
            if (!map || map.len !== this.user.nickname.length) {
                map = {
                    user_id: this.user.userId,
                    len: this.user.nickname.length,
                    at: [],
                };
                mentions.push(map);
            }
            map.at.push(lastAt + 1);
            chat.text += `@${this.user.nickname}`;
        }

멘션의 append함수를 이렇게 수정한 결과 폰에서도 잘 보임. 완벽하게 수정이 안되었을수도 있으므로 풀리퀘는 안넣도록 함.

JellyBrick commented 3 years ago

@nunnu1028 일단 dev 브랜치에 PR 넣는게 좋을 것 같아요

nunnu1028 commented 3 years ago

@JellyBrick https://github.com/storycraft/node-kakao/commit/277fa7cce0f5597bc7343ef7d32f2f601e41aac2 수정된거 같은데요?