Bump cinny: local API message and unread endpoints by scope.
All checks were successful
All checks were successful
This commit is contained in:
2
cinny
2
cinny
Submodule cinny updated: 0da4f0d6cb...82b22fa739
@@ -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') {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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: {
|
||||
|
||||
10
test-api.js
10
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');
|
||||
|
||||
Reference in New Issue
Block a user