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

add option to delete a user's messages #4362

Merged
merged 2 commits into from
Sep 14, 2021
Merged

Conversation

ebbit1q
Copy link
Member

@ebbit1q ebbit1q commented May 18, 2021

Related Ticket(s)

Short roundup of the initial problem

users say mean things sometimes and we'd like to forget that

What will change with this Pull Request?

  • add options to redact messages when warning or banning a user
  • add event to clients that redacts said messages when requested

@ebbit1q
Copy link
Member Author

ebbit1q commented May 30, 2021

This is ready for TESTING, please TEST this feature before merging it

#include <QTextEdit>

const QColor DEFAULT_MENTION_COLOR = QColor(194, 31, 47);

UserMessagePosition::UserMessagePosition(QTextCursor &cursor)
{
Copy link
Member

Choose a reason for hiding this comment

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

What does this function do? I'm confused

Copy link
Member Author

Choose a reason for hiding this comment

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

it's the constructor for the message position, it saves the block and the position in the block it references

UserLevelFlags userLevel,
QString UserPrivLevel,
bool playerBold)
{
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
bool sameSender = (sender == lastSender) && !lastSender.isEmpty();
// messageType should be Event_RoomSay::UserMessage though we don't actually check
bool isUserMessage = !(userName.toLower() == "servatrice" || userName.isEmpty());
Copy link
Member

Choose a reason for hiding this comment

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

double hardcoded name, make into a const

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like this name to begin with, I wanted to leave this check as similar as possible, when is "servatrice" talking anyway? only when the user talks or will it actually set it to servatrice otherwise?


// timestamp
if (showTimestamps && (!sameSender || sender.toLower() == "servatrice") && !sender.isEmpty()) {
if (showTimestamps && ((!sameSender && isUserMessage) || userName.toLower() == "servatrice")) {
Copy link
Member

Choose a reason for hiding this comment

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

better comments, i don't understand this

Copy link
Member Author

Choose a reason for hiding this comment

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

it's better than the previous check

bool removedLastMessage = false;
QTextCursor cursor(document());
for (; !messagePositions.isEmpty() && amount != 0; --amount) {
auto position = messagePositions.takeLast(); // go backwards from last message
Copy link
Member

Choose a reason for hiding this comment

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

This is very complicated

Copy link
Member Author

Choose a reason for hiding this comment

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

and? qt's cursor for document editing is trash?

add optional parameter remove_messages to the ban and warn commands
add event for clients to redact messages
implement server side command and message handling
implement server history removal
todo: client side implementation

add option to remove messages to moderator action dialogs

add storage of message beginnings to chatview

add redactMessage command
handle Event_RemoveMessages on rooms

this approach is favored over parsing the chatroom after the fact but
will use additional memory to store the block indexes

this also leaves a problem in that user messages from the chat backlog
are not removed in the same way because they don't have a user
associated with them

add workaround for old qt versions

add action for users to remove messages from users in chats

add chat history to userMessagePositions with regex

proper const usage for userName

allow removing the messages of unregistered users

add menus to usernames in chat history

this allows you to remove user messages on chat history as well
this also allows moderators to take actions on users in chat history

Apply suggestions from code review
Copy link
Member

@ZeldaZach ZeldaZach left a comment

Choose a reason for hiding this comment

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

Tested and works as expected

@ZeldaZach ZeldaZach merged commit 1e995cd into Cockatrice:master Sep 14, 2021
@ebbit1q ebbit1q deleted the fix_3917 branch September 14, 2021 20:43
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.

Deleting Messages in Main Chat
2 participants