-
Notifications
You must be signed in to change notification settings - Fork 6
feat(discord): inbound + outbound media attachments #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| { | ||
| "name": "@openhermit/channel-discord", | ||
| "private": true, | ||
| "version": "0.2.0", | ||
| "version": "0.3.0", | ||
| "type": "module", | ||
| "main": "src/index.ts", | ||
| "scripts": { | ||
| "build": "tsc -b", | ||
| "typecheck": "tsc -p tsconfig.typecheck.json --pretty false", | ||
| "test": "node --import tsx --test test/*.test.ts", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if tsx is declared in this package or workspace root
cat apps/channels/discord/package.json | jq -r '.dependencies.tsx // .devDependencies.tsx // "not found"'
# Check workspace root if this is a monorepo
if [ -f package.json ]; then
echo "Workspace root tsx:"
cat package.json | jq -r '.dependencies.tsx // .devDependencies.tsx // "not found"'
fi
# Try running the test script to see if it fails
cd apps/channels/discord && npm test 2>&1 | head -20Repository: HCF-STUDIOS/openhermit Length of output: 1115 Fix test script so
🤖 Prompt for AI Agents |
||
| "dev": "tsx src/index.ts" | ||
| }, | ||
| "dependencies": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { test } from 'node:test'; | ||
|
|
||
| import { mapRawAttachments } from '../src/bot.js'; | ||
|
|
||
| test('mapRawAttachments maps gateway-dispatch attachments to the neutral shape', () => { | ||
| const mapped = mapRawAttachments([ | ||
| { url: 'https://cdn.discordapp.com/a.png', filename: 'a.png', content_type: 'image/png', size: 1234 }, | ||
| { url: 'https://cdn.discordapp.com/b.pdf', filename: 'b.pdf', content_type: 'application/pdf', size: 99 }, | ||
| ]); | ||
| assert.deepEqual(mapped, [ | ||
| { url: 'https://cdn.discordapp.com/a.png', name: 'a.png', contentType: 'image/png', size: 1234 }, | ||
| { url: 'https://cdn.discordapp.com/b.pdf', name: 'b.pdf', contentType: 'application/pdf', size: 99 }, | ||
| ]); | ||
| }); | ||
|
|
||
| test('mapRawAttachments tolerates missing fields and non-arrays', () => { | ||
| assert.deepEqual(mapRawAttachments(undefined), []); | ||
| assert.deepEqual(mapRawAttachments('nope'), []); | ||
| assert.deepEqual(mapRawAttachments([{ url: 'https://x/y' }]), [ | ||
| { url: 'https://x/y', name: 'attachment' }, | ||
| ]); | ||
| // Entries without a url are dropped. | ||
| assert.deepEqual(mapRawAttachments([{ filename: 'no-url.txt' }]), []); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.