Skip to content

Commit

Permalink
feat: support RPL_ISUPPORT CLIENTTAGDENY
Browse files Browse the repository at this point in the history
This is useful for clients which want to do graceful
degradations of client tags features such as typing, reacts, replies, etc.
  • Loading branch information
RaitoBezarius committed Aug 11, 2023
1 parent f2989ca commit 29d49a6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/commands/handlers/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const handlers = {
handler.network.options.CHANMODES = option[1].split(',');
} else if (option[0] === 'CASEMAPPING') {
handler.network.options.CASEMAPPING = option[1];
} else if (option[0] === 'CLIENTTAGDENY' && handler.network.cap.isEnabled('message-tags')) {
handler.network.options.CLIENTTAGDENY = option[1].split(',');
} else if (option[0] === 'NETWORK') {
handler.network.name = option[1];
} else if (option[0] === 'NAMESX' && !handler.network.cap.isEnabled('multi-prefix')) {
Expand Down
3 changes: 2 additions & 1 deletion src/networkinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function NetworkInfo() {
{ symbol: '@', mode: 'o' },
{ symbol: '%', mode: 'h' },
{ symbol: '+', mode: 'v' }
]
],
CLIENTTAGDENY: []
};

this.time_offsets = [];
Expand Down
30 changes: 30 additions & 0 deletions test/networkinfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,35 @@ describe('src/networkinfo.js', function() {
const results = names.map(name => client.network.isChannelName(name));
assert.deepEqual(results, [false, false, false, false, false, false]);
});

it('should parse CLIENTTAGDENY= as a list', function() {
const client = newMockClient();
client.dispatch({
command: '005',
params: ['nick', 'CLIENTTAGDENY='],
tags: []
});
assert.isEmpty(client.network.options.CLIENTTAGDENY);
});

it('should parse CLIENTTAGDENY=*,-a,-b as a list', function() {
const client = newMockClient();
client.dispatch({
command: '005',
params: ['nick', 'CLIENTTAGDENY=*,-a,-b'],
tags: []
});
assert.equal(client.network.options.CLIENTTAGDENY, ['*', '-a', '-b']);
});
});

it('should parse CLIENTTAGDENY=a,b,c as a list', function() {
const client = newMockClient();
client.dispatch({
command: '005',
params: ['nick', 'CLIENTTAGDENY=a,b,c'],
tags: []
});
assert.equal(client.network.options.CLIENTTAGDENY, ['a', 'b', 'c']);
});
});

0 comments on commit 29d49a6

Please sign in to comment.