Skip to content

Rs/add simple slack notification #478

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

RonanMorgan
Copy link
Collaborator

Give the possibility to activate slack notification into a channel (one channel per organisation)

=> Add an endpoint in the organizations/ path in order to activate the slack notification by registering the SLACK_HOOK
=> Create a SLACK service, similar to the Telegram service
=> modify the create_detection endpoint in on order to add the notification creation

Copy link

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 68.51852% with 17 lines in your changes missing coverage. Please review.

Project coverage is 84.09%. Comparing base (14d58dc) to head (0f1b8f7).

Files with missing lines Patch % Lines
src/app/services/slack.py 74.19% 8 Missing ⚠️
src/app/api/api_v1/endpoints/detections.py 12.50% 7 Missing ⚠️
src/app/api/api_v1/endpoints/organizations.py 88.88% 1 Missing ⚠️
src/app/main.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #478      +/-   ##
==========================================
- Coverage   84.79%   84.09%   -0.70%     
==========================================
  Files          38       39       +1     
  Lines        1151     1201      +50     
==========================================
+ Hits          976     1010      +34     
- Misses        175      191      +16     
Flag Coverage Δ
backend 83.42% <68.51%> (-0.72%) ⬇️
client 93.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@frgfm
Copy link
Member

frgfm commented Jun 11, 2025

I might be mistaking but it looks like you forgot to remove cv2 and/or pillow + the extra dependencies from Docker

Copy link
Member

@frgfm frgfm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! A few remaining questions but nothing major

@@ -10,7 +10,6 @@ ENV PYTHONPATH="/app"
# Install curl
RUN apt-get -y update \
&& apt-get -y install curl libmagic1 \
&& apt-get clean \
Copy link
Member

Choose a reason for hiding this comment

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

Can you please revert this please?

@@ -134,6 +139,18 @@ async def create_detection(
org = cast(Organization, await organizations.get(token_payload.organization_id, strict=True))
if org.telegram_id:
background_tasks.add_task(telegram_client.notify, org.telegram_id, det.model_dump_json())

if slack_client.is_enabled:
org = cast(Organization, await organizations.get(token_payload.organization_id, strict=True))
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid the double call if telegram and slack client are enabled

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hum I don't understand, what is the issue here ?

organizations: OrganizationCRUD = Depends(get_organization_crud),
token_payload: TokenPayload = Security(get_jwt, scopes=[UserRole.ADMIN]),
) -> Organization:
telemetry_client.capture(
Copy link
Member

Choose a reason for hiding this comment

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

This isn't relevant for product analytics, no need to add the event capture :)

@@ -17,6 +17,7 @@ pydantic = ">=2.0.0,<3.0.0"
pydantic-settings = ">=2.0.0,<3.0.0"
requests = "^2.32.0"
PyJWT = "^2.8.0"
bcrypt = "<4.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

Can you elaborate on this one? (it's already in the passlib extra) did you encounter a bug with the lockfile?

@@ -55,6 +55,7 @@ services:
- S3_ACCESS_KEY=fake
- S3_SECRET_KEY=fake
- S3_REGION=us-east-1
- SLACK_HOOK=${SLACK_HOOK}
Copy link
Member

Choose a reason for hiding this comment

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

if I understand this correctly, this is the admin org slack hook?
If so I think it shouldn't be initialized in the DB initialization script + validated in the config
If not, let's remove it?

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 used only for testing purpose

Copy link
Member

Choose a reason for hiding this comment

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

boto3 was already on the version you specified, why is the entire lockfile updated? can you please revert? Check my comment in pyproject but if bcrypt is indeed not needed, we don't need to change the lockfile

(please don't bump versions without a reason)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants