MCPcopy
hub / github.com/callumalpass/tasknotes / processItem

Method processItem

src/services/AutoArchiveService.ts:190–275  ·  view source on GitHub ↗

* Process a single auto-archive item * @returns true if successfully processed, false if should be retried

(item: PendingAutoArchive)

Source from the content-addressed store, hash-verified

188 * @returns true if successfully processed, false if should be retried
189 */
190 private async processItem(item: PendingAutoArchive): Promise<boolean> {
191 // Get current task to verify it still exists and has the expected status
192 const currentTask = await this.plugin.cacheManager.getTaskByPath(item.taskPath);
193
194 if (!currentTask) {
195 // Task no longer exists, consider processed
196 return true;
197 }
198
199 if (
200 this.normalizeStatusValue(currentTask.status) !==
201 this.normalizeStatusValue(item.statusValue)
202 ) {
203 // Task status changed since scheduling, consider processed
204 return true;
205 }
206
207 if (currentTask.archived) {
208 if (this.hasGoogleCalendarLink(currentTask)) {
209 const calendarCleanupState = this.getCalendarCleanupState();
210 if (calendarCleanupState === "skip") {
211 return true;
212 }
213
214 if (calendarCleanupState === "retry") {
215 tasknotesLogger.warn(
216 `Auto-archive Google cleanup deferred until calendar sync is ready for ${item.taskPath}`,
217 {
218 category: "provider",
219 operation:
220 "auto-archive-google-cleanup-deferred-until-calendar-sync-ready",
221 }
222 );
223 return false;
224 }
225
226 const deleted =
227 await this.plugin.taskCalendarSyncService.deleteTaskFromCalendar(currentTask);
228 if (!deleted) {
229 tasknotesLogger.warn(
230 `Auto-archive Google cleanup still pending for ${item.taskPath}`,
231 {
232 category: "provider",
233 operation: "auto-archive-google-cleanup-still-pending",
234 }
235 );
236 }
237 return deleted;
238 }
239
240 // Task already archived, consider processed
241 return true;
242 }
243
244 // Archive the task
245 try {
246 const archivedTask = await this.plugin.taskService.toggleArchive(currentTask);
247 if (archivedTask.archived && this.hasGoogleCalendarLink(archivedTask)) {

Calls 8

normalizeStatusValueMethod · 0.95
hasGoogleCalendarLinkMethod · 0.95
warnMethod · 0.80
errorMethod · 0.80
getTaskByPathMethod · 0.45
toggleArchiveMethod · 0.45

Tested by

no test coverage detected