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

Adjusted user mention parsing, added tests, and parsing for attachment fallback. #44

Merged
merged 2 commits into from
May 8, 2024

Conversation

coltoneshaw
Copy link
Member

@coltoneshaw coltoneshaw commented Jan 10, 2024

Summary

When importing from slack I noticed <!here> was not properly converted at all. This adjusted the regex to find both <@here> and <!here>

Additionally, added parsing for attachment fallbacks because they use the mention syntax.

Before the change:

test <!here> test
test @channel test
test @all test
test @user1 test
test <@user1> test

Before the change:

test @here test
test @channel test
test @all test
test @user1 test
test <@user1> test

@coltoneshaw
Copy link
Member Author

I don't believe <@user1> is the correct parsing here and I'm happy to adjust. I'm just not sure what we were looking for in slack, so I haven't touched it. https://community.mattermost.com/private-core/pl/6wd3kptwmfnhzdgqeb9a4wtcuh

@coltoneshaw coltoneshaw changed the title Adjusted parsing on user mentions and added a test Adjusted user mention parsing, added tests, and parsing for attachment fallback. Jan 10, 2024

if post.Attachments != nil {
for _, attachment := range post.Attachments {
attachment.Fallback = r.ReplaceAllString(attachment.Fallback, mention)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand this line. Doesn't this effectively do the following?

Suggested change
attachment.Fallback = r.ReplaceAllString(attachment.Fallback, mention)
attachment.Fallback = mention

Copy link
Member Author

Choose a reason for hiding this comment

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

if so, wouldn't we modify the above string too?

post.Text = r.ReplaceAllString(post.Text, mention)

It's just passing the mention regex into replace

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand now. I didn't realize r was its own regex

@coltoneshaw coltoneshaw merged commit 25a5413 into master May 8, 2024
2 checks passed
@coltoneshaw coltoneshaw deleted the userMentionParsing branch May 8, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants