From 2b20aee3dd58c0ef00bd1209bf72f68e69bb59cb Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 9 May 2023 14:54:25 +0800 Subject: [PATCH] feat: add starred event push for github service --- .../com.msgbyte.github/services/subscribe.service.ts | 10 ++++++++++ .../src/GroupSubscribePanel/index.tsx | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/server/plugins/com.msgbyte.github/services/subscribe.service.ts b/server/plugins/com.msgbyte.github/services/subscribe.service.ts index 6138005b..985cbef3 100644 --- a/server/plugins/com.msgbyte.github/services/subscribe.service.ts +++ b/server/plugins/com.msgbyte.github/services/subscribe.service.ts @@ -228,6 +228,16 @@ class GithubSubscribeService extends TcService { } await this.sendMessageToSubscribes(ctx, repo, message); + } else if ('starred_at' in event) { + if (event.action === 'created') { + const name = event.sender.login; + const userUrl = event.sender.html_url; + const repo = event.repository.full_name; + const repoUrl = event.repository.html_url; + const repoStarCount = event.repository.stargazers_count; + const message = `[url=${userUrl}]${name}[/url] starred [url=${repoUrl}]${repo}[/url](total ${repoStarCount} stargazers)`; + await this.sendMessageToSubscribes(ctx, repo, message); + } } } diff --git a/server/plugins/com.msgbyte.github/web/plugins/com.msgbyte.github/src/GroupSubscribePanel/index.tsx b/server/plugins/com.msgbyte.github/web/plugins/com.msgbyte.github/src/GroupSubscribePanel/index.tsx index 648c3305..2584c1c6 100644 --- a/server/plugins/com.msgbyte.github/web/plugins/com.msgbyte.github/src/GroupSubscribePanel/index.tsx +++ b/server/plugins/com.msgbyte.github/web/plugins/com.msgbyte.github/src/GroupSubscribePanel/index.tsx @@ -1,14 +1,19 @@ import React, { useCallback, useMemo } from 'react'; import { - openModal, - closeModal, useGroupIdContext, useAsyncRefresh, useAsyncRequest, getServiceUrl, useGroupPanelInfo, } from '@capital/common'; -import { Button, CopyableText, Space, Table } from '@capital/component'; +import { + openModal, + closeModal, + Button, + CopyableText, + Space, + Table, +} from '@capital/component'; import { Translate } from '../translate'; import { AddGroupSubscribeModal } from './AddGroupSubscribeModal'; import { request } from '../request';