-
Notifications
You must be signed in to change notification settings - Fork 225
Add SendMessageInterceptor
to intercept send message request
#3671
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9d87de5
Add ChatMessage.changing + improve docs of ChatMessage.replacing
nuno-vieira f512286
Add `SendMessageInterceptor`
nuno-vieira b11a12c
Implement SendMessageInterceptor in MessageRepository
nuno-vieira 494d847
Create separate functions to handle the normal message request and th…
nuno-vieira a2b4000
Use a factory to allow for more flexibility, especially to make it po…
nuno-vieira 4e3b575
Example on how to use our internal sendMessage as an interceptor
nuno-vieira af3dbfa
Revert "Example on how to use our internal sendMessage as an intercep…
nuno-vieira 0480a9c
Fix some minor typos
nuno-vieira e391102
Update CHANGELOG.md
nuno-vieira a278241
Add test coverage to replacing() and changing() functions
nuno-vieira 6c95117
Add Message Repository test coverage
nuno-vieira 8306692
Merge branch 'develop' into add/send-message-interceptor
nuno-vieira aef38d2
PR Feedback
nuno-vieira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Copyright © 2025 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A struct that contains additional info when sending messages. | ||
public struct SendMessageOptions { | ||
public let skipPush: Bool | ||
public let skipEnrichUrl: Bool | ||
} | ||
|
||
/// A struct that represents the response when sending a message. | ||
public struct SendMessageResponse { | ||
public let message: ChatMessage | ||
|
||
public init(message: ChatMessage) { | ||
self.message = message | ||
} | ||
} | ||
|
||
/// A protocol that defines a way to intercept messages before sending them to the server. | ||
public protocol SendMessageInterceptor { | ||
func sendMessage( | ||
_ message: ChatMessage, | ||
options: SendMessageOptions, | ||
completion: @escaping ((Result<SendMessageResponse, Error>) -> Void) | ||
) | ||
} | ||
|
||
/// A factory responsible for creating message interceptors. | ||
public protocol SendMessageInterceptorFactory { | ||
func makeSendMessageInterceptor(client: ChatClient) -> SendMessageInterceptor | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.