Skip to content

PRIVMSG is malformed for DMs? #103

Open
@fancypantalons

Description

@fancypantalons

I'm honestly amazed I didn't noticed this before. In the IRC specification, a private message to an individual takes the form:

:<originator> PRIVMSG <target> <text>

Ultimately, the code to send a PRIVMSG in response to a Slack message looks like this:

self.ircd.write(ircUser.socket, ircNick, 'PRIVMSG', [ ircTarget, ':' + line ]);

Where ircTarget is determined as follows:

let [ircNick, ircTarget] = await this.resolveSlackTarget(ircUser, event);

If we dive into the codepath, here, we ultimately end up at resolveSlackChannel, which contains this snippet:

// If it's an im, pass to resolveSlackUser
if (convo.channel.is_im) {
  return this.resolveSlackUser(ircUser, convo.channel.user);
}

And so, for a DM, the target is set to the person who sent the message. But... that's not right! The target is supposed to be the receiver of the message (i.e., ourselves). This code ends up producing the following message:

:<originator> PRIVMSG <originator> <text>

I'm pretty sure this code should read:

// If it's an im, we're the target, so return our own nick
if (convo.channel.is_im) {
  return ircUser.ircNick;
}

I think it just happens that IRC clients are willing to handle these malformed messages. But it produces all kinds of weird results, not the least being that ZNC refuses to buffer DMs coming from irslackd.

I would've just generated a PR, but I wanted to get a second set of eyes on this first. Does this look right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions