Skip to content

Commit

Permalink
More realistic test
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Mar 27, 2024
1 parent 46a0d65 commit b4ed0bd
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
node-version: '20.x'

- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
Expand All @@ -33,7 +33,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
Expand All @@ -48,6 +48,8 @@ jobs:
env:
NOSTR_PRIVATE_KEY: ${{ secrets.NOSTR_PRIVATE_KEY }}
OPENAI_API_CSV: anyvalueworksformockedtests
SLACK_TOKEN: something
CHANNEL_ID: something
run: pnpm test

- name: Upload coverage to Codecov
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@google-cloud/datastore": "^8.2.1",
"@google-cloud/functions-framework": "^3.0.0",
"@nostr-dev-kit/ndk": "^1.3.1",
"@slack/web-api": "^7.0.2",
"nostr-tools": "^1.16.0",
"openai": "^4.11.1",
"ws": "^8.14.2"
Expand Down
103 changes: 103 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 14 additions & 9 deletions src/lib/slack.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { WebClient } = require("@slack/web-api");
import { WebClient } from "@slack/web-api";

if (!process.env.SLACK_TOKEN) {
throw new Error("SLACK_TOKEN environment variable is required");
Expand All @@ -13,16 +13,18 @@ const channelId = process.env.CHANNEL_ID;
const web = new WebClient(token);
export default class Slack {
static async postManualVerification(reportRequest) {
// console.log(
// `TODO: Implement Slack.postManualVerification.\n
// Event payload: ${JSON.stringify(reportRequest.reportedEvent)}\n
// Reporter pubkey: ${reportRequest.reporterPubkey}\n
// Reporter text: ${reportRequest.reporterText}`
// );
try {
const result = await web.chat.postMessage({
channel: channelId,
text: "This is a sample message with buttons",
text: `Pubkey ${
reportRequest.reporterPubkey
} reported an event:\n\`\`\`\n${
reportRequest.reporterText
}\`\`\`\nEvent to evaluate:\n\`\`\`\n${JSON.stringify(
reportRequest.reportedEvent,
null,
2
)}\n\`\`\``,
blocks: [
{
type: "section",
Expand Down Expand Up @@ -56,7 +58,10 @@ export default class Slack {
},
],
});
console.log(result);

console.log(
`Sent event ${reportRequest.reportedEvent.id} to Slack for manual evaluation.`
);
} catch (error) {
console.error(error);
}
Expand Down

0 comments on commit b4ed0bd

Please sign in to comment.