Skip to content

Commit

Permalink
feat(service): update postNewMessage payload
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jan 18, 2024
1 parent 2cfd7f2 commit 603f150
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/components/NewMessage/NewMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ export default {
* Sends the new message
*
* @param {object} options the submit options
* @param {boolean} options.silent whether the message should trigger notifications
*/
async handleSubmit(options) {
// Submit event has enter key listener
Expand Down
11 changes: 5 additions & 6 deletions src/services/messagesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,20 @@ const getMessageContext = async function({ token, messageId, limit = 50 }, optio
*
* @param {object} param0 The message object that is destructured
* @param {string} param0.token The conversation token
* @param {string} param0.message The message object
* @param {string} param0.message The message text
* @param {string} param0.actorDisplayName The display name of the actor
* @param {string} param0.referenceId A reference id to identify the message later again
* @param {object|undefined} param0.parent The message to be replied to
* @param {object} options request options
* @param {boolean} options.silent whether the message should trigger a notifications for the
* recipients or not
* @param {object} param1 options object destructured
* @param {boolean} param1.silent whether the message should trigger a notifications
*/
const postNewMessage = async function({ token, message, actorDisplayName, referenceId, parent }, options) {
const postNewMessage = async function({ token, message, actorDisplayName, referenceId, parent }, { silent, ...options }) {
return axios.post(generateOcsUrl('apps/spreed/api/v1/chat/{token}', { token }), {
message,
actorDisplayName,
referenceId,
replyTo: parent?.id,
silent: options.silent,
silent,
}, options)
}

Expand Down
2 changes: 2 additions & 0 deletions src/services/messagesService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe('messagesService', () => {
referenceId: 'reference-id',
parent: { id: 111 },
}, {
silent: false,
dummyOption: true,
})

Expand All @@ -133,6 +134,7 @@ describe('messagesService', () => {
actorDisplayName: 'actor-display-name',
referenceId: 'reference-id',
replyTo: 111,
silent: false,
},
{
dummyOption: true,
Expand Down
3 changes: 1 addition & 2 deletions src/store/messagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,7 @@ const actions = {
}
}

const response = await postNewMessage(message, { silent: false })
return response
return await postNewMessage(message, { silent: false })

},

Expand Down

0 comments on commit 603f150

Please sign in to comment.