koishi-plugin-githubsth 1.0.1-test7 → 1.0.1-test8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,28 +29,31 @@ class Notifier extends koishi_1.Service {
29
29
  async handleEvent(event, payload) {
30
30
  // FORCE LOG for debugging
31
31
  this.ctx.logger('githubsth').info(`Received event: ${event}`);
32
- let repoName = payload.repository?.full_name;
32
+ // Check if payload is nested in an 'event' object (common in some adapter versions)
33
+ // or if the event data is directly in payload
34
+ const realPayload = payload.payload || payload;
35
+ let repoName = realPayload.repository?.full_name;
33
36
  // Try to fallback if repoName is missing
34
- if (!repoName && payload.issue?.repository_url) {
35
- const parts = payload.issue.repository_url.split('/');
37
+ if (!repoName && realPayload.issue?.repository_url) {
38
+ const parts = realPayload.issue.repository_url.split('/');
36
39
  if (parts.length >= 2) {
37
40
  repoName = `${parts[parts.length - 2]}/${parts[parts.length - 1]}`;
38
41
  }
39
42
  }
40
- if (!repoName && payload.pull_request?.base?.repo?.full_name) {
41
- repoName = payload.pull_request.base.repo.full_name;
43
+ if (!repoName && realPayload.pull_request?.base?.repo?.full_name) {
44
+ repoName = realPayload.pull_request.base.repo.full_name;
42
45
  }
43
46
  if (!repoName) {
44
47
  this.ctx.logger('githubsth').warn(`Missing repo info for event: ${event}`);
45
48
  if (this.config.debug) {
46
- this.ctx.logger('notifier').warn(`Event ${event} missing repository info. Keys: ${Object.keys(payload).join(', ')}`);
49
+ this.ctx.logger('notifier').warn(`Event ${event} missing repository info. Keys: ${Object.keys(realPayload).join(', ')}`);
47
50
  }
48
51
  return;
49
52
  }
50
53
  this.ctx.logger('githubsth').info(`Processing event ${event} for ${repoName}`);
51
54
  if (this.config.debug) {
52
55
  this.ctx.logger('notifier').info(`Received event ${event} for ${repoName}`);
53
- this.ctx.logger('notifier').debug(JSON.stringify(payload, null, 2));
56
+ this.ctx.logger('notifier').debug(JSON.stringify(realPayload, null, 2));
54
57
  }
55
58
  // Get rules from database
56
59
  const dbRules = await this.ctx.database.get('github_subscription', {
@@ -69,7 +72,7 @@ class Notifier extends koishi_1.Service {
69
72
  return true;
70
73
  });
71
74
  if (matchedRules.length === 0) {
72
- this.ctx.logger('githubsth').info(`No matching rules for ${repoName}`);
75
+ this.ctx.logger('githubsth').info(`No matching rules for ${repoName} (event: ${event})`);
73
76
  if (this.config.debug) {
74
77
  this.ctx.logger('notifier').debug(`No matching rules for ${repoName} (event: ${event})`);
75
78
  }
@@ -87,34 +90,34 @@ class Notifier extends koishi_1.Service {
87
90
  }
88
91
  switch (event) {
89
92
  case 'push':
90
- message = this.ctx.githubsthFormatter.formatPush(payload);
93
+ message = this.ctx.githubsthFormatter.formatPush(realPayload);
91
94
  break;
92
95
  case 'issues':
93
- message = this.ctx.githubsthFormatter.formatIssue(payload);
96
+ message = this.ctx.githubsthFormatter.formatIssue(realPayload);
94
97
  break;
95
98
  case 'pull_request':
96
- message = this.ctx.githubsthFormatter.formatPullRequest(payload);
99
+ message = this.ctx.githubsthFormatter.formatPullRequest(realPayload);
97
100
  break;
98
101
  case 'star':
99
- message = this.ctx.githubsthFormatter.formatStar(payload);
102
+ message = this.ctx.githubsthFormatter.formatStar(realPayload);
100
103
  break;
101
104
  case 'fork':
102
- message = this.ctx.githubsthFormatter.formatFork(payload);
105
+ message = this.ctx.githubsthFormatter.formatFork(realPayload);
103
106
  break;
104
107
  case 'release':
105
- message = this.ctx.githubsthFormatter.formatRelease(payload);
108
+ message = this.ctx.githubsthFormatter.formatRelease(realPayload);
106
109
  break;
107
110
  case 'discussion':
108
- message = this.ctx.githubsthFormatter.formatDiscussion(payload);
111
+ message = this.ctx.githubsthFormatter.formatDiscussion(realPayload);
109
112
  break;
110
113
  case 'workflow_run':
111
- message = this.ctx.githubsthFormatter.formatWorkflowRun(payload);
114
+ message = this.ctx.githubsthFormatter.formatWorkflowRun(realPayload);
112
115
  break;
113
116
  case 'issue_comment':
114
- message = this.ctx.githubsthFormatter.formatIssueComment(payload);
117
+ message = this.ctx.githubsthFormatter.formatIssueComment(realPayload);
115
118
  break;
116
119
  case 'pull_request_review':
117
- message = this.ctx.githubsthFormatter.formatPullRequestReview(payload);
120
+ message = this.ctx.githubsthFormatter.formatPullRequestReview(realPayload);
118
121
  break;
119
122
  }
120
123
  if (!message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-githubsth",
3
- "version": "1.0.1-test7",
3
+ "version": "1.0.1-test8",
4
4
  "description": "Github Subscriptions Notifications, push notifications for GitHub subscriptions For koishi",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",