( notification: GitifyNotification, )
| 12 | } |
| 13 | |
| 14 | export 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 | } |
no test coverage detected