Skip to content

Commit 7dd2117

Browse files
delthasemersion
authored andcommitted
Add support for incoming REDACT
This does not include support for redacting messages, only reading incoming REDACT messages. See: ircv3/ircv3-specifications#524
1 parent ca0cfdc commit 7dd2117

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

components/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ export default class App extends Component {
762762

763763
// Open a new buffer if the message doesn't come from me or is a
764764
// self-message
765-
if ((!client.isMyNick(msg.prefix.name) || client.isMyNick(bufName)) && (msg.command !== "PART" && msg.comand !== "QUIT" && msg.command !== irc.RPL_MONONLINE && msg.command !== irc.RPL_MONOFFLINE)) {
765+
if ((!client.isMyNick(msg.prefix.name) || client.isMyNick(bufName)) && (msg.command !== "PART" && msg.command !== "QUIT" && msg.command !== irc.RPL_MONONLINE && msg.command !== irc.RPL_MONOFFLINE)) {
766766
this.createBuffer(serverID, bufName);
767767
}
768768

@@ -1075,6 +1075,7 @@ export default class App extends Component {
10751075
case "ACK":
10761076
case "BOUNCER":
10771077
case "MARKREAD":
1078+
case "REDACT":
10781079
// Ignore these
10791080
return [];
10801081
default:

components/buffer.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function canFoldMessage(msg) {
9494

9595
class LogLine extends Component {
9696
shouldComponentUpdate(nextProps) {
97-
return this.props.message !== nextProps.message;
97+
return this.props.message !== nextProps.message || this.props.redacted !== nextProps.redacted;
9898
}
9999

100100
render() {
@@ -143,13 +143,18 @@ class LogLine extends Component {
143143
`;
144144
}
145145
} else {
146-
lineClass = "talk";
147146
let prefix = "<", suffix = ">";
148147
if (msg.command === "NOTICE") {
149148
lineClass += " notice";
150149
prefix = suffix = "-";
151150
}
152-
content = html`<span class="nick-caret">${prefix}</span>${createNick(msg.prefix.name)}<span class="nick-caret">${suffix}</span> ${linkify(stripANSI(text), onChannelClick)}`;
151+
if (this.props.redacted) {
152+
content = html`<i>This message has been deleted.</i>`;
153+
} else {
154+
content = html`${linkify(stripANSI(text), onChannelClick)}`;
155+
lineClass += " talk";
156+
}
157+
content = html`<span class="nick-caret">${prefix}</span>${createNick(msg.prefix.name)}<span class="nick-caret">${suffix}</span> ${content}`;
153158
}
154159

155160
let allowedPrefixes = server.statusMsg;
@@ -710,6 +715,7 @@ export default class Buffer extends Component {
710715
message=${msg}
711716
buffer=${buf}
712717
server=${server}
718+
redacted=${buf.redacted.has(msg.tags.msgid)}
713719
onChannelClick=${onChannelClick}
714720
onNickClick=${onNickClick}
715721
onVerifyClick=${onVerifyClick}

lib/client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const permanentCaps = [
2121
"draft/account-registration",
2222
"draft/chathistory",
2323
"draft/extended-monitor",
24+
"draft/message-redaction",
2425
"draft/read-marker",
2526

2627
"soju.im/bouncer-networks",

state.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ export const State = {
361361
hasInitialWho: false, // if channel
362362
members: new irc.CaseMapMap(null, client.cm), // if channel
363363
messages: [],
364+
redacted: new Set(),
364365
unread: Unread.NONE,
365366
prevReadReceipt: null,
366367
});
@@ -665,6 +666,14 @@ export const State = {
665666

666667
return { members };
667668
});
669+
case "REDACT":
670+
target = msg.params[0];
671+
if (client.isMyNick(target)) {
672+
target = msg.prefix.name;
673+
}
674+
return updateBuffer(target, (buf) => {
675+
return { redacted: new Set(buf.redacted).add(msg.params[1]) };
676+
});
668677
case irc.RPL_MONONLINE:
669678
case irc.RPL_MONOFFLINE:
670679
targets = msg.params[1].split(",");

0 commit comments

Comments
 (0)