MCPcopy
hub / github.com/gitify-app/gitify / generateGitHubWebUrl

Function generateGitHubWebUrl

src/renderer/utils/notifications/url.ts:14–55  ·  view source on GitHub ↗
(
  notification: GitifyNotification,
)

Source from the content-addressed store, hash-verified

12}
13
14export async function generateGitHubWebUrl(
15 notification: GitifyNotification,
16): Promise<Link> {
17 const handler = createNotificationHandler(notification);
18 const url = new URL(handler.defaultUrl(notification));
19
20 if (notification.subject.htmlUrl) {
21 url.href = notification.subject.htmlUrl;
22 } else {
23 try {
24 if (notification.subject.latestCommentUrl) {
25 const response = await getHtmlUrl(
26 notification.account,
27 notification.subject.latestCommentUrl,
28 );
29
30 url.href = response.html_url;
31 } else if (notification.subject.url) {
32 const response = await getHtmlUrl(
33 notification.account,
34 notification.subject.url,
35 );
36
37 url.href = response.html_url;
38 }
39 } catch (err) {
40 rendererLogError(
41 'generateGitHubWebUrl',
42 'Failed to resolve specific notification html url for',
43 toError(err),
44 notification,
45 );
46 }
47 }
48
49 url.searchParams.set(
50 'notification_referrer_id',
51 generateNotificationReferrerId(notification),
52 );
53
54 return url.toString() as Link;
55}

Callers 3

url.test.tsFile · 0.90
openNotificationFunction · 0.90
raiseNativeNotificationFunction · 0.90

Calls 7

getHtmlUrlFunction · 0.90
rendererLogErrorFunction · 0.90
toErrorFunction · 0.90
toStringMethod · 0.80
defaultUrlMethod · 0.65

Tested by

no test coverage detected