From 4949ceea4585311c9fce0c0e73a655b5953917d3 Mon Sep 17 00:00:00 2001 From: Josh Freda Date: Wed, 14 Jun 2023 16:18:10 -0500 Subject: [PATCH] Lock documents on other types of suggestions in the header (#212) * Lock documents on other types of suggestions in the header * Separate log line for locked draft docs * Add comments per PR feedback --- internal/indexer/refresh_headers.go | 6 +++++- pkg/hashicorpdocs/locked.go | 28 +++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/internal/indexer/refresh_headers.go b/internal/indexer/refresh_headers.go index 2a64fffd9..cac266ba0 100644 --- a/internal/indexer/refresh_headers.go +++ b/internal/indexer/refresh_headers.go @@ -89,7 +89,11 @@ func refreshDocumentHeaders( } lockedDocIDs = append(lockedDocIDs, d.GoogleFileID) } - log.Info(fmt.Sprintf("locked document IDs: %v", lockedDocIDs)) + if ft == draftsFolderType { + log.Info(fmt.Sprintf("locked draft document IDs: %v", lockedDocIDs)) + } else { + log.Info(fmt.Sprintf("locked document IDs: %v", lockedDocIDs)) + } // Return if there are no updated documents. if len(docs) == 0 { diff --git a/pkg/hashicorpdocs/locked.go b/pkg/hashicorpdocs/locked.go index 2e6c5bda9..a28d6347f 100644 --- a/pkg/hashicorpdocs/locked.go +++ b/pkg/hashicorpdocs/locked.go @@ -104,15 +104,41 @@ func containsSuggestionInHeader(doc *docs.Document) bool { // Navigate through all table contents to look for suggestions. for _, row := range t.TableRows { + // Check table rows for suggestions. + if len(row.SuggestedDeletionIds) > 0 || + len(row.SuggestedInsertionIds) > 0 || + len(row.SuggestedTableRowStyleChanges) > 0 { + // We found a suggestion. + return true + } for _, cell := range row.TableCells { + // Check table cells for suggestions. + if len(cell.SuggestedDeletionIds) > 0 || + len(cell.SuggestedInsertionIds) > 0 || + len(cell.SuggestedTableCellStyleChanges) > 0 { + return true + } for _, content := range cell.Content { + // Check table cell content for suggestions. if para := content.Paragraph; para != nil { + if len(para.SuggestedBulletChanges) > 0 || + len(para.SuggestedParagraphStyleChanges) > 0 || + len(para.SuggestedPositionedObjectIds) > 0 { + return true + } for _, elem := range para.Elements { + // Check table cell paragraphs for suggestions. + if auto := elem.AutoText; auto != nil { + if len(auto.SuggestedDeletionIds) > 0 || + len(auto.SuggestedInsertionIds) > 0 || + len(auto.SuggestedTextStyleChanges) > 0 { + return true + } + } if txt := elem.TextRun; txt != nil { if len(txt.SuggestedDeletionIds) > 0 || len(txt.SuggestedInsertionIds) > 0 || len(txt.SuggestedTextStyleChanges) > 0 { - // We found a suggestion. return true } }