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

Add endpoint to create slack channel for a given proposal #76

Merged
merged 30 commits into from
May 18, 2024

Conversation

stuartcampbell
Copy link
Collaborator

Added endpoint to create a Slack channel for a proposal.

It will add the "bot" to the channel and then add all the beamline slack managers and all the proposal users that have a valid username.

Also added an endpoint for the beamline to list the slack channel managers

Note: currently the line to actually add external users is commented out until we are sure this works ok.

stuartcampbell and others added 23 commits February 7, 2024 12:37
This commit adds the SlackChannelManagersView model to the beamlines.py file in the src/nsls2api/models directory. The model includes a list of slack_channel_managers and a projection setting for the corresponding database field. This model will be used to manage the Slack channel managers for each beamline.
The commit adds a new endpoint `/beamline/{name}/slack-channel-managers` to the `beamline_api.py` file in the `src/nsls2api/api/v1` directory. This endpoint allows users to retrieve the Slack channel managers for a specific beamline. If the beamline is not found, a 404 error is returned.
This commit adds the SlackUser model to the `slack_models.py` file in the `src/nsls2api/models` directory. The model includes fields for `user_id`, `username`, and `email`. This model will be used to represent a Slack user in the application.
This commit adds functionality to retrieve the Slack user IDs of the channel managers for a given beamline. It introduces a new function `slack_channel_managers` in the `beamline_service.py` file. The function takes the name of the beamline as input and returns a list of Slack user IDs. It also includes necessary error handling if the beamline is not found.
@stuartcampbell stuartcampbell added the enhancement New feature or request label May 11, 2024
@stuartcampbell stuartcampbell self-assigned this May 11, 2024
)

# TODO: Uncomment to actually add the users when we are sure!!
# slack_service.add_users_to_channel(channel_id=channel_id, user_ids=proposal_user_ids)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the line that needs to be uncommented to add all the users to the slack channel

Copy link
Collaborator

@padraic-shafer padraic-shafer left a comment

Choose a reason for hiding this comment

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

This is a very nice addition to the API services. I've noted some things for consideration.

src/nsls2api/services/slack_service.py Show resolved Hide resolved
src/nsls2api/services/slack_service.py Show resolved Hide resolved
src/nsls2api/models/beamlines.py Show resolved Hide resolved
src/nsls2api/models/beamlines.py Outdated Show resolved Hide resolved
src/nsls2api/api/v1/admin_api.py Outdated Show resolved Hide resolved
src/nsls2api/models/slack_models.py Outdated Show resolved Hide resolved
src/nsls2api/api/v1/admin_api.py Show resolved Hide resolved
Copy link
Collaborator

@padraic-shafer padraic-shafer left a comment

Choose a reason for hiding this comment

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

Looks good!

@padraic-shafer padraic-shafer merged commit c118bcf into NSLS2:main May 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants