Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Comments

Auto create a user for app#195

Merged
d-gubert merged 52 commits intobetafrom
auto-create-user-for-app
Jan 13, 2020
Merged

Auto create a user for app#195
d-gubert merged 52 commits intobetafrom
auto-create-user-for-app

Conversation

@shiqimei
Copy link
Contributor

@shiqimei shiqimei commented Nov 29, 2019

  • Review @Cool-fire's PR Interface to create Bot user through Apps.engine (#133)
  • Create new role App. Base the permission of this role of the bot role, since they will be very similar
  • During App installation, create a user with the App
  • Add an "appId" field on the user that links it to the app
  • Prevent "App users" from logging-in on Rocket.Chat
  • Make the App's user the default sender for the messages sent by app

👉 The PR in the Rocket.Chat side: RocketChat/Rocket.Chat#15896

@shiqimei shiqimei changed the title Auto create user for app Auto create a user for app Nov 29, 2019
@codecov
Copy link

codecov bot commented Nov 29, 2019

Codecov Report

Merging #195 into master will increase coverage by 0.08%.
The diff coverage is 58.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
+ Coverage   56.97%   57.06%   +0.08%     
==========================================
  Files          76       77       +1     
  Lines        2536     2599      +63     
  Branches      362      368       +6     
==========================================
+ Hits         1445     1483      +38     
- Misses       1091     1116      +25
Impacted Files Coverage Δ
src/server/compiler/AppFabricationFulfillment.ts 61.11% <0%> (-12.23%) ⬇️
src/server/accessors/index.ts 100% <100%> (ø) ⬆️
src/server/accessors/ModifyUpdater.ts 95.55% <100%> (ø) ⬆️
src/server/AppManager.ts 14.62% <4.76%> (-0.41%) ⬇️
src/server/accessors/ModifyCreator.ts 72.72% <80%> (-0.29%) ⬇️
src/server/accessors/UserBuilder.ts 94.28% <94.28%> (ø)

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 e835628...1039ac4. Read the comment docs.

@shiqimei shiqimei self-assigned this Dec 3, 2019
@shiqimei shiqimei added the 🆕 enhancement An enhancement which can be a new feature. label Dec 3, 2019
Apply (Abstract) Factory pattern here, we can extend this interface to add other types of users.
return new UserBuilder(data);
}

public finish(builder: IMessageBuilder | ILivechatMessageBuilder | IRoomBuilder | IUserBuilder): Promise<string> {
Copy link
Member

Choose a reason for hiding this comment

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

This keeps haunting us... I wonder if it isn't time we stopped following this start/finish pattern 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we also remove the IUserBuilder and UserBuilder from the code base?

Copy link
Member

@d-gubert d-gubert Dec 10, 2019

Choose a reason for hiding this comment

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

No, I don't think so. I think for now we just enable Apps to call a modify.getCreator().finishUser(builder: IUserBuilder) - this is going to make it possible to stop adding types on the finish method. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean make different finish*() methods standalone?

Copy link
Contributor

Choose a reason for hiding this comment

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

@d-gubert One thing to note is that if you go that route, you will have to introduce a breaking change and all of the previous Apps will no longer work on new installations. The reason I say you will "have to" is because if you have two places for them to do it then it's not a clear and concise. If you don't want this method to be so long, then create a specific type above for it like:

type BuilderFinisher = IMessageBuilder | ILivechatMessageBuilder | IRoomBuilder | IUserBuilder;

Then in the finish method do public finish(builder: BuilderFinisher): Promise<string>

Copy link
Member

Choose a reason for hiding this comment

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

@graywolf336 I think that could be a solution for now :)

But I don't think that introducing new ways of achieving things in the engine should require breaking changes - we can always deprecate APIs and keep them around for compatibility reasons until the time comes for the next major version. Even if it means having "two places for them to do it then it's not clear and concise". This could be solved by improving our docs effort (which we definitely have to)

Do you mean make different finish*() methods standalone?

@lolimay that's what I was thinking, but let's maybe leave this change for another PR

@graywolf336
Copy link
Contributor

@d-gubert @lolimay Question. Rocket.Chat Servers are billed for their seats on Cloud and when it comes to App Subscriptions. So, us enabling Apps to create users raises the question of whether the users created by Apps are billable or not. What are your thoughts on this? Because if a developer decided to go rough, they could create a lot of users and then cause the Server to be billed for a ton of users.

@d-gubert d-gubert requested a review from rodrigok January 7, 2020 22:07
@d-gubert d-gubert marked this pull request as ready for review January 8, 2020 15:03
@d-gubert d-gubert changed the base branch from master to beta January 13, 2020 21:29
@d-gubert d-gubert dismissed rodrigok’s stale review January 13, 2020 21:29

Changes applied

@d-gubert d-gubert merged commit 9aa34d1 into beta Jan 13, 2020
@sampaiodiego sampaiodiego deleted the auto-create-user-for-app branch February 6, 2020 19:02
@sampaiodiego sampaiodiego restored the auto-create-user-for-app branch February 6, 2020 19:02
@d-gubert d-gubert deleted the auto-create-user-for-app branch February 24, 2020 15:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🆕 enhancement An enhancement which can be a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants