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

Fix #1450 slack_file in image block/element #1452

Merged
merged 3 commits into from Jan 31, 2024

Conversation

seratch
Copy link
Member

@seratch seratch commented Jan 26, 2024

Summary

This pull request resolves #1450

Category (place an x in each of the [ ])

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.signature (Request Signature Verifier)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.models (UI component builders)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.rtm_v2 (RTM client)
  • /docs-src (Documents, have you run ./scripts/docs.sh?)
  • /docs-src-v2 (Documents, have you run ./scripts/docs-v2.sh?)
  • /tutorial (PythOnBoardingBot tutorial)
  • tests/integration_tests (Automated tests for this library)

Requirements (place an x in each [ ])

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.sh after making the changes.

@seratch seratch added enhancement M-T: A feature request for new functionality web-client Version: 3x labels Jan 26, 2024
@seratch seratch added this to the 3.27.0 milestone Jan 26, 2024
@seratch seratch requested a review from filmaj January 26, 2024 06:06
@seratch seratch self-assigned this Jan 26, 2024
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dc96f5f) 85.34% compared to head (42d2bc0) 85.36%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1452      +/-   ##
==========================================
+ Coverage   85.34%   85.36%   +0.01%     
==========================================
  Files         111      111              
  Lines       12273    12289      +16     
==========================================
+ Hits        10475    10491      +16     
  Misses       1798     1798              

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

Copy link
Contributor

@filmaj filmaj 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 taking this on! Left a few suggestions and questions for my own learning.

@@ -559,3 +559,25 @@ def to_dict(self) -> Dict[str, Any]: # skipcq: PYL-W0221
else:
json["trigger"] = self._trigger
return json


class SlackFile(JsonObject):
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added the comment for this class!

slack_sdk/models/blocks/basic_components.py Show resolved Hide resolved
if self._id is not None:
json["id"] = self._id
if self._url is not None:
json["url"] = self._url
Copy link
Contributor

Choose a reason for hiding this comment

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

If a user sets both, then both properties would be set. According to the docs on this object, this would result in the payload being rejected:

This file must be an image and you must provide either the URL or ID. In addition, the user posting these blocks must have access to this file. If both are provided then the payload will be rejected.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's true but runtime error with server side error should be okay. i would like to avoid having duplicated logic on the client side for this (we already have a lot in this sdk but maintaining them is a concern I've been thinking about)

alt_text (required): A plain-text summary of the image. This should not contain any markup.
image_url: The URL of the image to be displayed.
slack_file: A Slack image file object that defines the source of the image.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we state that either image_url or slack_file is required somewhere here?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, but in this sdk we don't mention such in comments

@seratch seratch merged commit 7e71b73 into slackapi:main Jan 31, 2024
12 checks passed
@seratch seratch deleted the issue-1450-slack-file branch January 31, 2024 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality Version: 3x web-client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "slack_file" properties to "image" blocks/elements under slack_sdk.models
2 participants