-
Notifications
You must be signed in to change notification settings - Fork 2
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
[CON-97] feat: add reaction methods #26
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
28d3294
feat: add message reactions SDK
ttypic 877a13f
feat: add presence
ttypic cc895ad
feat: provide auth header
ttypic 26f4f0d
fix: server token details
ttypic 34ab922
fix: mock reactions calls
ttypic 6adccd2
feat: update demo
ttypic 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 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 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 |
---|---|---|
|
@@ -24,6 +24,10 @@ export interface UpdateMessageResponse { | |
id: string; | ||
} | ||
|
||
export interface AddReactionResponse { | ||
id: string; | ||
} | ||
|
||
/** | ||
* Chat SDK Backend | ||
*/ | ||
|
@@ -109,4 +113,26 @@ export class ChatApi { | |
}); | ||
if (!response.ok) throw new ErrorInfo(response.statusText, response.status, 4000); | ||
} | ||
|
||
async addMessageReaction(conversationId: string, messageId: string, type: string): Promise<AddReactionResponse> { | ||
const response = await fetch(`${this.baseUrl}/v1/conversations/${conversationId}/messages/${messageId}/reactions`, { | ||
method: 'POST', | ||
headers: { | ||
'ably-clientId': this.clientId, | ||
}, | ||
body: JSON.stringify({ type }), | ||
}); | ||
if (!response.ok) throw new ErrorInfo(response.statusText, response.status, 4000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps another branch to change this as aware this is in other places too, but if the response is an ErrorInfo type, all the information we need to create an ErrorInfo will be in the response :) |
||
return response.json(); | ||
} | ||
|
||
async deleteMessageReaction(reactionId: string): Promise<void> { | ||
const response = await fetch(`${this.baseUrl}/v1/conversations/reactions/${reactionId}`, { | ||
method: 'DELETE', | ||
headers: { | ||
'ably-clientId': this.clientId, | ||
}, | ||
}); | ||
if (!response.ok) throw new ErrorInfo(response.statusText, response.status, 4000); | ||
} | ||
} |
This file contains 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 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 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So just to check my understanding, would this be the "room-level" reactions, whereas the message-level ones would be the example above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right