Skip to content

Make the Slack API return the response when posting a message#286

Merged
obelisk merged 1 commit intomainfrom
api/slack/return_response
Mar 19, 2026
Merged

Make the Slack API return the response when posting a message#286
obelisk merged 1 commit intomainfrom
api/slack/return_response

Conversation

@michelemin
Copy link
Collaborator

@michelemin michelemin commented Mar 18, 2026

Add Slack API Response Capturing for post_message Functions

⚠️ This PR is breaking-recompile. Existing rules must be recompiled with the new STL. ⚠️

Summary

Enhanced the Slack post_message and post_message_with_blocks functions to capture and return API responses from Slack, enabling callers to access message metadata (such as message timestamps) returned by the Slack API.

Changes

Slack STL Module (mod.rs)

  • Added new detailed variants: Created post_message_detailed() and post_message_with_blocks_detailed() functions that return Result<String, PlaidFunctionError> containing the full Slack API response
  • Backward compatibility: Existing post_message() and post_message_with_blocks() functions now delegate to their detailed counterparts and discard the response, maintaining the original Result<(), PlaidFunctionError> signature
  • Updated host function integration: Switched from new_host_function! to new_host_function_with_error_buffer! macro to support response capture
  • Added return buffer handling: Implemented 32 KiB buffer for capturing API responses

Runtime API Layer (api.rs)

  • Changed post_message() return type from Result<u32> to Result<String>
  • Modified function to return the actual Slack API response instead of returning 0

Function Registration (api.rs)

  • Updated slack post_message registration from impl_new_function! to impl_new_function_with_error_buffer! macro

Dependencies

  • Minor dependency updates in Cargo.lock (getrandom: 0.3.3 → 0.3.4, rand: 0.9.1 → 0.9.2)

Motivation

Previously, Slack message posting functions discarded the API response, preventing users from accessing important metadata like message timestamps. This change enables use cases that require the response data while maintaining backward compatibility for existing code.

@michelemin michelemin requested review from obelisk and wbssbw March 18, 2026 07:27
@michelemin michelemin added the breaking-recompile There is an API change but compiling against the newest STL will maintain module compatibility. label Mar 18, 2026
@obelisk obelisk merged commit 1dd5ef6 into main Mar 19, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-recompile There is an API change but compiling against the newest STL will maintain module compatibility.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants