From 658ff1215cb77b45baa486c23a78897ebac80984 Mon Sep 17 00:00:00 2001 From: litruv Date: Mon, 3 Aug 2026 15:08:22 +1000 Subject: [PATCH] Bump cinny: local API message and unread endpoints by scope. --- cinny | 2 +- electron/api-server.js | 80 ++++++++++++++++++++++++- paarrot-api.postman_collection.json | 75 ++++++++++++++++++++++++ scripts/generate-postman-collection.js | 81 ++++++++++++++++++++++++++ test-api.js | 10 ++++ 5 files changed, 246 insertions(+), 2 deletions(-) diff --git a/cinny b/cinny index 0da4f0d..82b22fa 160000 --- a/cinny +++ b/cinny @@ -1 +1 @@ -Subproject commit 0da4f0d6cb1fe86a890fe20453b2d8552b1f20a0 +Subproject commit 82b22fa739195f7b0758c5214622b7ea61c5e7c0 diff --git a/electron/api-server.js b/electron/api-server.js index 6fb6cca..52e149f 100644 --- a/electron/api-server.js +++ b/electron/api-server.js @@ -153,6 +153,72 @@ class PaarrotAPIServer { } }); + // Recent messages across group channels (non-DMs) + this.app.get('/messages/groups', async (req, res) => { + try { + const result = await this.executeAction('get-messages-groups', { + limit: req.query.limit, + }); + res.json({ success: true, data: result }); + } catch (error) { + res.status(500).json({ success: false, error: error.message }); + } + }); + + // Recent messages across DMs + this.app.get('/messages/dms', async (req, res) => { + try { + const result = await this.executeAction('get-messages-dms', { + limit: req.query.limit, + }); + res.json({ success: true, data: result }); + } catch (error) { + res.status(500).json({ success: false, error: error.message }); + } + }); + + // Recent messages across groups + DMs + this.app.get('/messages/combined', async (req, res) => { + try { + const result = await this.executeAction('get-messages-combined', { + limit: req.query.limit, + }); + res.json({ success: true, data: result }); + } catch (error) { + res.status(500).json({ success: false, error: error.message }); + } + }); + + // Unread conversations across group channels (non-DMs) + this.app.get('/unreads/groups', async (req, res) => { + try { + const result = await this.executeAction('get-unreads-groups'); + res.json({ success: true, data: result }); + } catch (error) { + res.status(500).json({ success: false, error: error.message }); + } + }); + + // Unread conversations across DMs + this.app.get('/unreads/dms', async (req, res) => { + try { + const result = await this.executeAction('get-unreads-dms'); + res.json({ success: true, data: result }); + } catch (error) { + res.status(500).json({ success: false, error: error.message }); + } + }); + + // Unread conversations across groups + DMs + this.app.get('/unreads/combined', async (req, res) => { + try { + const result = await this.executeAction('get-unreads-combined'); + res.json({ success: true, data: result }); + } catch (error) { + res.status(500).json({ success: false, error: error.message }); + } + }); + // 404 handler this.app.use((req, res) => { res.status(404).json({ @@ -169,7 +235,13 @@ class PaarrotAPIServer { 'GET /channels', 'POST /message', 'POST /message/current', - 'GET /room/current' + 'GET /room/current', + 'GET /messages/groups', + 'GET /messages/dms', + 'GET /messages/combined', + 'GET /unreads/groups', + 'GET /unreads/dms', + 'GET /unreads/combined' ] }); }); @@ -237,6 +309,12 @@ class PaarrotAPIServer { console.log(' POST /message'); console.log(' POST /message/current'); console.log(' GET /room/current'); + console.log(' GET /messages/groups'); + console.log(' GET /messages/dms'); + console.log(' GET /messages/combined'); + console.log(' GET /unreads/groups'); + console.log(' GET /unreads/dms'); + console.log(' GET /unreads/combined'); resolve(port); }).on('error', (err) => { if (err.code === 'EADDRINUSE') { diff --git a/paarrot-api.postman_collection.json b/paarrot-api.postman_collection.json index 737cb4c..1be7aee 100644 --- a/paarrot-api.postman_collection.json +++ b/paarrot-api.postman_collection.json @@ -208,6 +208,81 @@ { "name": "Messaging", "item": [ + { + "name": "Get Group Messages", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/messages/groups?limit=10", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "messages", + "groups" + ], + "query": [ + { + "key": "limit", + "value": "10", + "description": "Number of recent messages (1-100, default 10)" + } + ] + }, + "description": "Get the most recent messages across joined group channels (non-DMs)." + } + }, + { + "name": "Get DM Messages", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/messages/dms?limit=10", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "messages", + "dms" + ], + "query": [ + { + "key": "limit", + "value": "10", + "description": "Number of recent messages (1-100, default 10)" + } + ] + }, + "description": "Get the most recent messages across joined direct messages." + } + }, + { + "name": "Get Combined Messages", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{baseUrl}}/messages/combined?limit=10", + "host": [ + "{{baseUrl}}" + ], + "path": [ + "messages", + "combined" + ], + "query": [ + { + "key": "limit", + "value": "10", + "description": "Number of recent messages (1-100, default 10)" + } + ] + }, + "description": "Get the most recent messages across groups and DMs together." + } + }, { "name": "Send Message to Room", "request": { diff --git a/scripts/generate-postman-collection.js b/scripts/generate-postman-collection.js index 28e9c17..83ec26b 100755 --- a/scripts/generate-postman-collection.js +++ b/scripts/generate-postman-collection.js @@ -164,6 +164,87 @@ const collection = { { name: 'Messaging', item: [ + { + name: 'Get Group Messages', + request: { + method: 'GET', + header: [], + url: { + raw: '{{baseUrl}}/messages/groups?limit=10', + host: ['{{baseUrl}}'], + path: ['messages', 'groups'], + query: [{ key: 'limit', value: '10', description: 'Number of recent messages (1-100, default 10)' }], + }, + description: 'Get the most recent messages across joined group channels (non-DMs).', + }, + }, + { + name: 'Get DM Messages', + request: { + method: 'GET', + header: [], + url: { + raw: '{{baseUrl}}/messages/dms?limit=10', + host: ['{{baseUrl}}'], + path: ['messages', 'dms'], + query: [{ key: 'limit', value: '10', description: 'Number of recent messages (1-100, default 10)' }], + }, + description: 'Get the most recent messages across joined direct messages.', + }, + }, + { + name: 'Get Combined Messages', + request: { + method: 'GET', + header: [], + url: { + raw: '{{baseUrl}}/messages/combined?limit=10', + host: ['{{baseUrl}}'], + path: ['messages', 'combined'], + query: [{ key: 'limit', value: '10', description: 'Number of recent messages (1-100, default 10)' }], + }, + description: 'Get the most recent messages across groups and DMs together.', + }, + }, + { + name: 'Get Group Unreads', + request: { + method: 'GET', + header: [], + url: { + raw: '{{baseUrl}}/unreads/groups', + host: ['{{baseUrl}}'], + path: ['unreads', 'groups'], + }, + description: 'List unread group conversations (non-DMs), including counts and latest message preview.', + }, + }, + { + name: 'Get DM Unreads', + request: { + method: 'GET', + header: [], + url: { + raw: '{{baseUrl}}/unreads/dms', + host: ['{{baseUrl}}'], + path: ['unreads', 'dms'], + }, + description: 'List unread DM conversations, including counts and latest message preview.', + }, + }, + { + name: 'Get Combined Unreads', + request: { + method: 'GET', + header: [], + url: { + raw: '{{baseUrl}}/unreads/combined', + host: ['{{baseUrl}}'], + path: ['unreads', 'combined'], + }, + description: 'List unread conversations across groups and DMs.', + }, + }, { name: 'Send Message to Room', request: { diff --git a/test-api.js b/test-api.js index 403924e..3cee1eb 100644 --- a/test-api.js +++ b/test-api.js @@ -60,6 +60,16 @@ async function runTests() { // Get current room await testEndpoint('Get Current Room', 'GET', '/room/current'); + + // Recent messages by scope + await testEndpoint('Get Group Messages', 'GET', '/messages/groups'); + await testEndpoint('Get DM Messages', 'GET', '/messages/dms'); + await testEndpoint('Get Combined Messages', 'GET', '/messages/combined?limit=10'); + + // Unread conversations by scope + await testEndpoint('Get Group Unreads', 'GET', '/unreads/groups'); + await testEndpoint('Get DM Unreads', 'GET', '/unreads/dms'); + await testEndpoint('Get Combined Unreads', 'GET', '/unreads/combined'); // Toggle mute await testEndpoint('Toggle Mute', 'POST', '/mute/toggle');