Skip to content

Commit

Permalink
Engine(-IRC): prevent highlights from self (closes: #1095)
Browse files Browse the repository at this point in the history
In theory, IRC is designed in a way in which all messages from
your current handle are always sent from your own client.

However, with the advent of IRC bridges, such as the Slack one,
it's feasible to use your IRC handle from 2 places: smuxi and
the web (slack UI). In this case, when you sent a message using
the latter, you would get a smuxi highlight on the former
because the engine receives a message that contains your nick,
which is essentially a false positive.

This can be workarounded by adding a comparison to Me's property
in MessageBuilder class just before highlighting.
  • Loading branch information
knocte committed Oct 23, 2016
1 parent af01536 commit ee6c3a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Engine-IRC/Protocols/Irc/IrcProtocolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3026,9 +3026,9 @@ private void _OnChannelMessage(object sender, IrcEventArgs e)
UpdateGroupPerson(chat, e.Data);

var builder = CreateMessageBuilder();
builder.AppendMessage(GetPerson(chat, e.Data.Nick ?? e.Data.From),
e.Data.Message);
builder.MarkHighlights();
PersonModel senderPerson = GetPerson(chat, e.Data.Nick ?? e.Data.From);
builder.AppendMessage(senderPerson, e.Data.Message);
builder.MarkHighlights(senderPerson);

var msg = builder.ToMessage();
Session.AddMessageToChat(chat, msg);
Expand All @@ -3038,18 +3038,19 @@ private void _OnChannelMessage(object sender, IrcEventArgs e)
e.Data.Channel)
);
}

private void _OnChannelAction(object sender, ActionEventArgs e)
{
var chat = GetChat(e.Data.Channel, ChatType.Group) ?? Chat;
UpdateGroupPerson(chat, e.Data);

var builder = CreateMessageBuilder();
builder.AppendActionPrefix();
builder.AppendIdendityName(GetPerson(chat, e.Data.Nick ?? e.Data.From));
PersonModel senderPerson = GetPerson(chat, e.Data.Nick ?? e.Data.From);
builder.AppendIdendityName(senderPerson);
builder.AppendText(" ");
builder.AppendMessage(e.ActionMessage);
builder.MarkHighlights();
builder.MarkHighlights(senderPerson);

var msg = builder.ToMessage();
Session.AddMessageToChat(chat, msg);
Expand Down
7 changes: 7 additions & 0 deletions src/Engine/Messages/MessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,13 @@ public virtual void MarkHighlights()
MarkAsHighlight();
}

public virtual void MarkHighlights(PersonModel sender)
{
if (sender != Me) {
MarkHighlights();
}
}

public virtual void MarkAsHighlight()
{
// colorize the whole message
Expand Down

0 comments on commit ee6c3a2

Please sign in to comment.