Skip to content

Auto create threads for suggestions #469

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

Merged
merged 7 commits into from
Jul 21, 2022
Merged

Auto create threads for suggestions #469

merged 7 commits into from
Jul 21, 2022

Conversation

Taz03
Copy link
Member

@Taz03 Taz03 commented Jul 19, 2022

Auto create thread for suggestions in suggestions channel.

Closes #468 .

image

@Taz03 Taz03 requested review from a team as code owners July 19, 2022 09:40
@CLAassistant
Copy link

CLAassistant commented Jul 19, 2022

CLA assistant check
All committers have signed the CLA.

@Taz03
Copy link
Member Author

Taz03 commented Jul 19, 2022

what to do about the spotless check?

Copy link
Member

@Zabuzard Zabuzard left a comment

Choose a reason for hiding this comment

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

Also, the code is not passing spotless.

@Zabuzard
Copy link
Member

what to do about the spotless check?

If you have set up the code locally and use the gradle commands, it would run spotless already for you. See our wiki for details on that.

@Taz03
Copy link
Member Author

Taz03 commented Jul 19, 2022

what the thread title should be "Discussion on User's suggestion" or "Discussion for User's suggestion" or something else

@Zabuzard
Copy link
Member

what the thread title should be "Discussion on User's suggestion" or "Discussion for User's suggestion" or something else

I dont care. Imo it is fine as u did it :)

Copy link
Member

@Zabuzard Zabuzard left a comment

Choose a reason for hiding this comment

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

This is a bit more tricky, but currently the UX suffers from the generic thread names:

issue

I think we can not release it like that and need some way to distinguish them.

I would suggest we determine the title based on the first x characters from the message. It is not perfect, but enough to make it clear what the thread is about. So in this case Discussion for 'I have a great idea' or just I have a great idea without the fuzz around it.

Code-wise, it could look something like message.getContent() and then substring(0, Math.min(MAX_LENGTH, content.length()). Where the max length could be something around 60 maybe.

If you want, you can also make the substring smarter by cutting off at the last "word" to not have something like I have a gre where its cut in the middle of the word. The code for something like already exists in ImplicitAskListener#createTitle where you can get some inspiration, if you want to.

@Taz03
Copy link
Member Author

Taz03 commented Jul 20, 2022

image
is this better?

@Zabuzard
Copy link
Member

image is this better?

Yes, but you have to ensure that its within the limit of thread names. So limit it to 60 characters for example. And if you do not want to cut it off in between a word, use a logic as shown earlier.

@Taz03
Copy link
Member Author

Taz03 commented Jul 20, 2022

yes, i did

    private static void createThread(@NotNull Message message) {
        String messageContent = message.getContentRaw();

        String title = messageContent;
        if (messageContent.length() >= TITLE_MAX_LENGTH) {
            int lastWordEnd = messageContent.lastIndexOf(' ', TITLE_MAX_LENGTH);

            if (lastWordEnd == -1) {
                lastWordEnd = TITLE_MAX_LENGTH;
            }

            title = messageContent.substring(0, lastWordEnd);
        }

        message
            .createThreadChannel(title)
            .queue();
    }

@Taz03
Copy link
Member Author

Taz03 commented Jul 20, 2022

image

Copy link
Member

@Zabuzard Zabuzard left a comment

Choose a reason for hiding this comment

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

Good stuff. Another thing that came to my mind, could you auto-invite the message author to the thread? Just add the user to it 🙂

@Taz03
Copy link
Member Author

Taz03 commented Jul 20, 2022

Any thread created will automatically invite the author and the member who created the thread

@Taz03 Taz03 requested a review from Zabuzard July 21, 2022 04:40
Copy link
Member

@Zabuzard Zabuzard left a comment

Choose a reason for hiding this comment

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

Seems to work well

tests

@Zabuzard
Copy link
Member

Zabuzard commented Jul 21, 2022

Waiting for a second approval. Otherwise merging in latest 7 days.

Thanks for your contribution, well done! 🎉

@Zabuzard Zabuzard merged commit 454f1aa into Together-Java:develop Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority: normal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto creation of threads in suggestion channel
4 participants