diff --git a/apps/github-app/.env.example b/apps/github-app/.env.example index cfc6f208..881ff64e 100644 --- a/apps/github-app/.env.example +++ b/apps/github-app/.env.example @@ -1,6 +1,7 @@ # The ID of your GitHub App APP_ID= WEBHOOK_SECRET=development +PRIVATE_KEY= # Use `trace` to get verbose logging or `info` to show less LOG_LEVEL=debug @@ -9,4 +10,6 @@ LOG_LEVEL=debug WEBHOOK_PROXY_URL= # Tailchat -TAILCHAT_API_URL= +TAILCHAT_API_URL=https://paw-server-nightly.moonrailgun.com +TAILCHAT_APP_ID= +TAILCHAT_APP_SECRET= diff --git a/apps/github-app/package.json b/apps/github-app/package.json index c40b4da2..99a76873 100644 --- a/apps/github-app/package.json +++ b/apps/github-app/package.json @@ -19,6 +19,7 @@ }, "dependencies": { "axios": "^0.21.1", + "dotenv": "^16.0.3", "probot": "^12.2.4", "probot-metadata": "^2.1.0" }, diff --git a/apps/github-app/src/app.ts b/apps/github-app/src/app.ts index 07497983..55e23387 100644 --- a/apps/github-app/src/app.ts +++ b/apps/github-app/src/app.ts @@ -2,6 +2,8 @@ import { Probot } from 'probot'; import metadata from 'probot-metadata'; import { TailchatClient } from './client'; import { configPath, generateErrorBlock } from './utils'; +import * as dotenv from 'dotenv'; // see https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import +dotenv.config(); const LABEL = 'tailchat-topic'; const TOPIC_KEY = 'tailchatTopicId'; @@ -53,6 +55,11 @@ export function app(app: Probot) { }\ncontent: ${ctx.payload.issue.body ?? ''}\n\nwebsite: ${ ctx.payload.issue.html_url }`, + meta: { + githubRepoOwner: ctx.payload.repository.owner, + githubRepoName: ctx.payload.repository.name, + githubIssueNumber: ctx.payload.issue.number, + }, } ); diff --git a/apps/github-app/src/index.ts b/apps/github-app/src/index.ts index 09489d7b..3cfdfff8 100644 --- a/apps/github-app/src/index.ts +++ b/apps/github-app/src/index.ts @@ -1,4 +1,8 @@ import { run } from 'probot'; import { app } from './app'; -run(app); +run(app).then((server) => { + server.router('/').get('/', (req, res) => { + res.send('Hello World! Github app server is working!'); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d6a55f41..31e5ac34 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -132,6 +132,7 @@ importers: '@types/jest': ^28.1.0 '@types/node': ^18.0.0 axios: ^0.21.1 + dotenv: ^16.0.3 jest: 27.5.1 nock: ^13.0.5 nodemon: ^2.0.18 @@ -143,6 +144,7 @@ importers: typescript: ^4.1.3 dependencies: axios: 0.21.4 + dotenv: 16.0.3 probot: 12.2.8 probot-metadata: 2.1.0_probot@12.2.8 devDependencies: @@ -14843,6 +14845,11 @@ packages: engines: {node: '>=12'} dev: false + /dotenv/16.0.3: + resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} + engines: {node: '>=12'} + dev: false + /dotenv/8.6.0: resolution: {integrity: sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==} engines: {node: '>=10'} @@ -19529,7 +19536,7 @@ packages: pretty-format: 27.5.1 slash: 3.0.0 strip-json-comments: 3.1.1 - ts-node: 10.9.1_bqee57coj3oib6dw4m24wknwqe + ts-node: 10.9.1_k2dsl7zculo2nmh5s33pladmoa transitivePeerDependencies: - bufferutil - canvas diff --git a/server/plugins/com.msgbyte.topic/models/topic.ts b/server/plugins/com.msgbyte.topic/models/topic.ts index 3878ca04..69455eed 100644 --- a/server/plugins/com.msgbyte.topic/models/topic.ts +++ b/server/plugins/com.msgbyte.topic/models/topic.ts @@ -51,6 +51,12 @@ export class GroupTopic extends TimeStamps implements db.Base { default: [], }) comments: GroupTopicComment[]; + + /** + * 话题的其他数据 + */ + @prop() + meta?: object; } export type GroupTopicDocument = db.DocumentType; diff --git a/server/plugins/com.msgbyte.topic/services/topic.service.ts b/server/plugins/com.msgbyte.topic/services/topic.service.ts index dcec56d5..de274788 100644 --- a/server/plugins/com.msgbyte.topic/services/topic.service.ts +++ b/server/plugins/com.msgbyte.topic/services/topic.service.ts @@ -29,6 +29,7 @@ class GroupTopicService extends TcService { groupId: 'string', panelId: 'string', content: 'string', + meta: { type: 'object', optional: true }, }, }); this.registerAction('createComment', this.createComment, { @@ -89,9 +90,10 @@ class GroupTopicService extends TcService { groupId: string; panelId: string; content: string; + meta?: object; }> ) { - const { groupId, panelId, content } = ctx.params; + const { groupId, panelId, content, meta } = ctx.params; const userId = ctx.meta.userId; const t = ctx.meta.t; @@ -112,6 +114,7 @@ class GroupTopicService extends TcService { groupId, panelId, content, + meta, author: userId, comment: [], });