( account: Account, settings: SettingsState, )
| 54 | * Endpoint documentation: https://docs.github.com/en/rest/activity/notifications#list-notifications-for-the-authenticated-user |
| 55 | */ |
| 56 | export async function listNotificationsForAuthenticatedUser( |
| 57 | account: Account, |
| 58 | settings: SettingsState, |
| 59 | ): Promise<ListNotificationsForAuthenticatedUserResponse> { |
| 60 | const octokit = await createOctokitClient(account, 'rest'); |
| 61 | |
| 62 | if (settings.fetchAllNotifications) { |
| 63 | // Fetch all pages using Octokit's pagination |
| 64 | return await octokit.paginate( |
| 65 | octokit.rest.activity.listNotificationsForAuthenticatedUser, |
| 66 | { |
| 67 | participating: settings.participating, |
| 68 | all: settings.fetchReadNotifications, |
| 69 | per_page: 100, |
| 70 | headers: { |
| 71 | 'Cache-Control': 'no-cache', // Prevent caching |
| 72 | }, |
| 73 | }, |
| 74 | ); |
| 75 | } |
| 76 | |
| 77 | // Single page request |
| 78 | const response = |
| 79 | await octokit.rest.activity.listNotificationsForAuthenticatedUser({ |
| 80 | participating: settings.participating, |
| 81 | all: settings.fetchReadNotifications, |
| 82 | per_page: 100, |
| 83 | headers: { |
| 84 | 'Cache-Control': 'no-cache', // Prevent caching |
| 85 | }, |
| 86 | }); |
| 87 | |
| 88 | return response.data; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Marks a thread as "read." Marking a thread as "read" is equivalent to |
no test coverage detected