* Transform a raw GitHub notification to GitifyNotification. * Called immediately after REST API response is received. * * This is the ONLY place where raw GitHub types should be converted * to Gitify's internal notification type. * * @param raw - The GitHub notification. * @param account - T
( raw: RawGitHubNotification, account: Account, )
| 43 | * @returns A transformed Gitify notification. |
| 44 | */ |
| 45 | function transformNotification( |
| 46 | raw: RawGitHubNotification, |
| 47 | account: Account, |
| 48 | ): GitifyNotification { |
| 49 | return { |
| 50 | id: raw.id, |
| 51 | unread: raw.unread, |
| 52 | updatedAt: raw.updated_at, |
| 53 | reason: transformReason(raw.reason), |
| 54 | subject: transformSubject(raw.subject), |
| 55 | repository: transformRepository(raw.repository), |
| 56 | account: account, |
| 57 | order: 0, // Will be set later in stabilizeNotificationsOrder |
| 58 | display: undefined as unknown as GitifyNotificationDisplay, // Display fields start as undefined, populated by formatNotification post-enrichment |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | function transformReason(raw: RawGitHubNotification['reason']): GitifyReason { |
| 63 | const reasonDetails = getReasonDetails(raw as Reason); |
no test coverage detected