Skip to content

Commit

Permalink
fix: change the value of channel.data.hidden to false when message.ne…
Browse files Browse the repository at this point in the history
…w event triggers (#1115)

Co-authored-by: martincupela <martin.cupela@gmail.com>
Co-authored-by: MartinCupela <32706194+MartinCupela@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 9, 2023
1 parent bc8a562 commit 9ecd345
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
11 changes: 8 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Reporting a Vulnerability

At Stream we are committed to the security of our Software. We appreciate your efforts in disclosing vulnerabilities responsibly and we will make every effort to acknowledge your contributions.

Report security vulnerabilities at the following email address:

```
[security@getstream.io](mailto:security@getstream.io)
```

Alternatively it is also possible to open a new issue in the affected repository, tagging it with the `security` tag.

A team member will acknowledge the vulnerability and will follow-up with more detailed information. A representative of the security team will be in touch if more information is needed.

# Information to include in a report

While we appreciate any information that you are willing to provide, please make sure to include the following:
* Which repository is affected
* Which branch, if relevant
* Be as descriptive as possible, the team will replicate the vulnerability before working on a fix.

- Which repository is affected
- Which branch, if relevant
- Be as descriptive as possible, the team will replicate the vulnerability before working on a fix.
4 changes: 4 additions & 0 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1387,10 +1387,14 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
}
break;
case 'channel.hidden':
channel.data = { ...channel.data, hidden: true };
if (event.clear_history) {
channelState.clearMessages();
}
break;
case 'channel.visible':
channel.data = { ...channel.data, hidden: false };
break;
default:
}

Expand Down
33 changes: 33 additions & 0 deletions test/unit/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,39 @@ describe('Channel _handleChannelEvent', function () {
});
});
});

it('should mark channel visible on channel.visible event', () => {
const channelVisibleEvent = {
type: 'channel.visible',
cid: 'messaging:id',
channel_id: 'id',
channel_type: 'messaging',
user: {
id: 'admin',
role: 'admin',
created_at: '2022-03-08T09:46:56.840739Z',
updated_at: '2022-03-15T08:30:09.796926Z',
last_active: '2023-05-24T09:20:31.041292724Z',
banned: false,
online: true,
},
created_at: '2023-05-24T09:20:43.986615426Z',
};
channel.data.hidden = true;

channel._handleChannelEvent(channelVisibleEvent);
expect(channel.data.hidden).eq(false);
});

it('should mark channel hidden on channel.hidden event', () => {
const channelVisibleEvent = {
type: 'channel.hidden',
};
channel.data.hidden = false;

channel._handleChannelEvent(channelVisibleEvent);
expect(channel.data.hidden).eq(true);
});
});

describe('Channels - Constructor', function () {
Expand Down

0 comments on commit 9ecd345

Please sign in to comment.