mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Add method to delete all private messages to REST API
Needed for https://code.briarproject.org/briar/briar-gtk/-/issues/11. Fixes #1782
This commit is contained in:
@@ -89,6 +89,9 @@ constructor(
|
||||
path("/messages/:contactId/read") {
|
||||
post { ctx -> messagingController.markMessageRead(ctx) }
|
||||
}
|
||||
path("/messages/:contactId/all") {
|
||||
delete { ctx -> messagingController.deleteAllMessages(ctx) }
|
||||
}
|
||||
path("/forums") {
|
||||
get { ctx -> forumController.list(ctx) }
|
||||
post { ctx -> forumController.create(ctx) }
|
||||
|
||||
@@ -10,4 +10,6 @@ interface MessagingController {
|
||||
|
||||
fun markMessageRead(ctx: Context): Context
|
||||
|
||||
fun deleteAllMessages(ctx: Context): Context
|
||||
|
||||
}
|
||||
|
||||
@@ -106,6 +106,16 @@ constructor(
|
||||
return MessageId(idBytes)
|
||||
}
|
||||
|
||||
override fun deleteAllMessages(ctx: Context): Context {
|
||||
val contactId = ctx.getContactIdFromPathParam()
|
||||
try {
|
||||
conversationManager.deleteAllMessages(contactId)
|
||||
} catch (e: NoSuchContactException) {
|
||||
throw NotFoundResponse()
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
override fun eventOccurred(e: Event) {
|
||||
when (e) {
|
||||
is ConversationMessageReceivedEvent<*> -> {
|
||||
|
||||
Reference in New Issue
Block a user