Danny 9793d81670
GC: Sharepoint: Pages info extended (#2461)
## Description
SharePoint details has a field `ParentPath`. This PR populates that field. 
Requires an additional call per collection to retrieve the Site's webURL. 
<!-- Insert PR description-->

## Does this PR need a docs update or release note?

- [x]  No 

## Type of change
- [x] 🧹 Tech Debt/Cleanup


## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
2023-02-23 19:43:10 +00:00

49 lines
1.1 KiB
Go

package sharepoint
import (
"time"
"github.com/alcionai/corso/src/internal/connector/graph/betasdk/models"
"github.com/alcionai/corso/src/pkg/backup/details"
)
// sharePointPageInfo propagates metadata from the SharePoint Page data type
// into searchable content.
// Page Details: https://learn.microsoft.com/en-us/graph/api/resources/sitepage?view=graph-rest-beta
func sharePointPageInfo(page models.SitePageable, root string, size int64) *details.SharePointInfo {
var (
name, prefix, webURL string
created, modified time.Time
)
if page.GetTitle() != nil {
name = *page.GetTitle()
}
if page.GetWebUrl() != nil {
if len(root) > 0 {
prefix = root + "/"
}
webURL = prefix + *page.GetWebUrl()
}
if page.GetCreatedDateTime() != nil {
created = *page.GetCreatedDateTime()
}
if page.GetLastModifiedDateTime() != nil {
modified = *page.GetLastModifiedDateTime()
}
return &details.SharePointInfo{
ItemType: details.SharePointItem,
ItemName: name,
ParentPath: root,
Created: created,
Modified: modified,
WebURL: webURL,
Size: size,
}
}