Augment post details with recipient information (#5027)

<!-- PR description-->
Posts are always sent to the group email address, along with additional
recipients if any. Currently, we don't have a way to get the unique
recipient list for individual posts due to graph api limitations.

Store the group mail address so that we can use it to populate the 'To'
field during Post -> EML exports.


---

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

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #<issue>

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abhishek Pandey 2024-01-22 21:18:37 -08:00 committed by GitHub
parent deead262ae
commit 90648ef564
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 6 deletions

View File

@ -19,15 +19,19 @@ var _ backupHandler[models.Conversationable, models.Postable] = &conversationsBa
type conversationsBackupHandler struct {
ac api.Conversations
protectedResource string
// SMTP address for the group
resourceEmail string
}
func NewConversationBackupHandler(
protectedResource string,
ac api.Conversations,
resourceEmail string,
) conversationsBackupHandler {
return conversationsBackupHandler{
ac: ac,
protectedResource: protectedResource,
resourceEmail: resourceEmail,
}
}
@ -134,6 +138,14 @@ func (bh conversationsBackupHandler) augmentItemInfo(
dgi *details.GroupsInfo,
c models.Conversationable,
) {
// Posts are always sent to the group email address, along with additional
// recipients if any. Currently we don't have a way to get the unique
// recipient list for individual posts due to graph api limitations.
//
// Store the group mail address in details so that SDK users can use it.
// This information will also be persisted in metadata files so that we
// can use it during export & restore.
dgi.Post.Recipients = []string{bh.resourceEmail}
dgi.Post.Topic = ptr.Val(c.GetTopic())
}

View File

@ -3,6 +3,7 @@ package groups
import (
"context"
"fmt"
"strings"
"github.com/alcionai/clues"
"github.com/kopia/kopia/repo/manifest"
@ -319,10 +320,17 @@ func backupConversations(
counter *count.Bus,
errs *fault.Bus,
) ([]data.BackupCollection, error) {
groupEmail := strings.Clone(ptr.Val(bc.group.GetMail()))
// This is unlikely, but if it does happen in the wild, we should investigate it.
if len(groupEmail) == 0 {
return nil, clues.New("group has no mail address")
}
var (
bh = groups.NewConversationBackupHandler(
bc.producerConfig.ProtectedResource.ID(),
bc.apiCli.Conversations())
bc.apiCli.Conversations(),
groupEmail)
colls []data.BackupCollection
)

View File

@ -64,6 +64,7 @@ type ConversationPostInfo struct {
CreatedAt time.Time `json:"createdAt,omitempty"`
Creator string `json:"creator,omitempty"`
Preview string `json:"preview,omitempty"`
Recipients []string `json:"recipients,omitempty"`
Size int64 `json:"size,omitempty"`
Topic string `json:"topic,omitempty"`
}