Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New room event #266

Merged
merged 12 commits into from
May 19, 2020
Merged

New room event #266

merged 12 commits into from
May 19, 2020

Conversation

d-gubert
Copy link
Member

@d-gubert d-gubert commented May 1, 2020

What? ⛵

  • Adds the new IPreRoomUserJoined event
  • Adds the new IPostRoomUserJoined event
  • Introduces the AppsEngineError class that signals prevention from apps events

Why? 🤔

The new event will allow apps to provide some access control to rooms.

Links 🌎

RocketChat/Rocket.Chat#17487

PS 👀

@d-gubert d-gubert marked this pull request as draft May 1, 2020 21:51
@d-gubert d-gubert changed the base branch from master to alpha May 1, 2020 21:53
@d-gubert d-gubert requested a review from rodrigok May 1, 2020 21:54
@codecov
Copy link

codecov bot commented May 1, 2020

Codecov Report

Merging #266 into alpha will decrease coverage by 1.36%.
The diff coverage is 14.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##            alpha     #266      +/-   ##
==========================================
- Coverage   53.05%   51.68%   -1.37%     
==========================================
  Files          74       74              
  Lines        2754     2790      +36     
  Branches      408      421      +13     
==========================================
- Hits         1461     1442      -19     
- Misses       1293     1348      +55     
Impacted Files Coverage Δ
src/server/AppManager.ts 14.39% <0.00%> (-0.18%) ⬇️
src/server/managers/AppListenerManager.ts 7.43% <15.78%> (-0.46%) ⬇️
src/server/ProxiedApp.ts 14.11% <20.00%> (+0.36%) ⬆️
src/server/rooms/Room.ts 57.89% <75.00%> (+4.95%) ⬆️
src/server/compiler/AppImplements.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3fe543...ed39c17. Read the comment docs.

src/definition/rooms/index.ts Show resolved Hide resolved
src/server/managers/AppListenerManager.ts Outdated Show resolved Hide resolved
src/definition/rooms/IPreRoomUserJoined.ts Outdated Show resolved Hide resolved
@d-gubert d-gubert marked this pull request as ready for review May 18, 2020 22:27
@@ -51,6 +51,13 @@ export class AppStatusUtilsDef {
return false;
}
}

public isError(status: AppStatus): boolean {
return [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a micro-optimization, but wouldn't it be better to have this array created static and as a constant instead of having to be created every time this method is called?

Copy link
Member Author

@d-gubert d-gubert May 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it would be slightly more efficient, indeed it is a micro-optimization. IMO it's clearer to read it that way, everything is inside the method's body.

If time comes we need this list elsewhere, no doubt we should extract to a static array. Right now I'm more inclined to go with the "clearer" version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I’m of the opposite opinion. I think it is more clear to read the code when it is reading a named variable/constant that expresses what it is for than to declare it in the body of the method being called.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking what you said as a rule is generally safer, but in this specific case, we have a bunch of things helping us: short method body; short method name; clear enum items named inside the array; few items inside it.

But should the situation be different, it would be worth it to go down a different path 😃

@d-gubert d-gubert merged commit d257eb8 into alpha May 19, 2020
@d-gubert d-gubert deleted the new-room-events branch May 19, 2020 13:34
@d-gubert d-gubert mentioned this pull request Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants