add messages
This commit is contained in:
@ -474,20 +474,40 @@ export async function listMessages(siteUrl, token, page = 1) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Recent conversations for the header dropdown. GET api/messages/recent.
|
||||
*
|
||||
* @param {string} siteUrl - canonical site base
|
||||
* @param {string} token - Bearer token
|
||||
* @param {number} [limit=5] - max rows
|
||||
* @return {Promise<object>}
|
||||
*/
|
||||
export async function recentMessages(siteUrl, token, limit = 5) {
|
||||
return ttpRequest({
|
||||
siteUrl,
|
||||
path: '/api/messages/recent',
|
||||
method: 'GET',
|
||||
token,
|
||||
query: { limit }
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* One conversation. GET api/messages/view/{id}.
|
||||
*
|
||||
* @param {string} siteUrl - canonical site base
|
||||
* @param {string} token - Bearer token
|
||||
* @param {string|number} id - conversation id
|
||||
* @param {boolean} [markRead=true] - false sends markRead=0
|
||||
* @return {Promise<object>}
|
||||
*/
|
||||
export async function viewMessage(siteUrl, token, id) {
|
||||
export async function viewMessage(siteUrl, token, id, markRead = true) {
|
||||
return ttpRequest({
|
||||
siteUrl,
|
||||
path: `/api/messages/view/${encodeURIComponent(id)}`,
|
||||
method: 'GET',
|
||||
token
|
||||
token,
|
||||
query: markRead ? undefined : { markRead: 0 }
|
||||
})
|
||||
}
|
||||
|
||||
@ -546,6 +566,23 @@ export async function readMessage(siteUrl, token, id) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a conversation unread. POST api/messages/unread/{id}.
|
||||
*
|
||||
* @param {string} siteUrl - canonical site base
|
||||
* @param {string} token - Bearer token
|
||||
* @param {string|number} id - conversation id
|
||||
* @return {Promise<object>}
|
||||
*/
|
||||
export async function unreadMessage(siteUrl, token, id) {
|
||||
return ttpRequest({
|
||||
siteUrl,
|
||||
path: `/api/messages/unread/${encodeURIComponent(id)}`,
|
||||
method: 'POST',
|
||||
token
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide a conversation. POST api/messages/delete/{id}.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user