use correct attachment size
This commit is contained in:
parent
cde2ea8492
commit
341bfd4616
46
.github/workflows/accSelector.yaml
vendored
46
.github/workflows/accSelector.yaml
vendored
@ -1,46 +0,0 @@
|
||||
name: SetM365AppAcc
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
outputs:
|
||||
client_app_slot:
|
||||
value: ${{ jobs.GetM365App.outputs.client_app_slot }}
|
||||
client_id_env:
|
||||
value: ${{ jobs.GetM365App.outputs.client_id_env }}
|
||||
client_secret_env:
|
||||
value: ${{ jobs.GetM365App.outputs.client_secret_env }}
|
||||
|
||||
jobs:
|
||||
GetM365App:
|
||||
environment: Testing
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
client_app_slot: ${{ steps.roundrobin.outputs.CLIENT_APP_SLOT }}
|
||||
client_id_env: ${{ steps.roundrobin.outputs.CLIENT_ID_ENV }}
|
||||
client_secret_env: ${{ steps.roundrobin.outputs.CLIENT_SECRET_ENV }}
|
||||
steps:
|
||||
- name: Figure out which client id to use
|
||||
id: roundrobin
|
||||
run: |
|
||||
slot=$((GITHUB_RUN_NUMBER % 4))
|
||||
echo "CLIENT_APP_SLOT=$slot" >> $GITHUB_OUTPUT
|
||||
|
||||
case $slot in
|
||||
|
||||
0)
|
||||
echo "CLIENT_ID_ENV=CLIENT_ID" >> $GITHUB_OUTPUT
|
||||
echo "CLIENT_SECRET_ENV=CLIENT_SECRET" >> $GITHUB_OUTPUT
|
||||
;;
|
||||
1)
|
||||
echo "CLIENT_ID_ENV=CLIENT_ID_2" >> $GITHUB_OUTPUT
|
||||
echo "CLIENT_SECRET_ENV=CLIENT_SECRET_2" >> $GITHUB_OUTPUT
|
||||
;;
|
||||
2)
|
||||
echo "CLIENT_ID_ENV=CLIENT_ID_3" >> $GITHUB_OUTPUT
|
||||
echo "CLIENT_SECRET_ENV=CLIENT_SECRET_3" >> $GITHUB_OUTPUT
|
||||
;;
|
||||
3)
|
||||
echo "CLIENT_ID_ENV=CLIENT_ID_4" >> $GITHUB_OUTPUT
|
||||
echo "CLIENT_SECRET_ENV=CLIENT_SECRET_4" >> $GITHUB_OUTPUT
|
||||
;;
|
||||
esac
|
||||
@ -134,6 +134,10 @@ func (c Mail) GetItem(
|
||||
immutableIDs bool,
|
||||
errs *fault.Bus,
|
||||
) (serialization.Parsable, *details.ExchangeInfo, error) {
|
||||
var (
|
||||
size int64
|
||||
attachSize int32
|
||||
)
|
||||
// Will need adjusted if attachments start allowing paging.
|
||||
headers := buildPreferHeaders(false, immutableIDs)
|
||||
itemOpts := &users.ItemMessagesMessageItemRequestBuilderGetRequestConfiguration{
|
||||
@ -146,7 +150,12 @@ func (c Mail) GetItem(
|
||||
}
|
||||
|
||||
if !ptr.Val(mail.GetHasAttachments()) && !HasAttachments(mail.GetBody()) {
|
||||
return mail, MailInfo(mail), nil
|
||||
return mail, MailInfo(mail, 0), nil
|
||||
}
|
||||
|
||||
bodySize := ptr.Val(mail.GetBody().GetContent())
|
||||
if bodySize != "" {
|
||||
size = int64(len(bodySize))
|
||||
}
|
||||
|
||||
options := &users.ItemMessagesItemAttachmentsRequestBuilderGetRequestConfiguration{
|
||||
@ -163,8 +172,13 @@ func (c Mail) GetItem(
|
||||
Attachments().
|
||||
Get(ctx, options)
|
||||
if err == nil {
|
||||
for _, a := range attached.GetValue() {
|
||||
attachSize = ptr.Val(a.GetSize())
|
||||
size = size + int64(attachSize)
|
||||
}
|
||||
|
||||
mail.SetAttachments(attached.GetValue())
|
||||
return mail, MailInfo(mail), nil
|
||||
return mail, MailInfo(mail, size), nil
|
||||
}
|
||||
|
||||
// A failure can be caused by having a lot of attachments as
|
||||
@ -214,11 +228,14 @@ func (c Mail) GetItem(
|
||||
}
|
||||
|
||||
atts = append(atts, att)
|
||||
|
||||
attachSize = ptr.Val(a.GetSize())
|
||||
size = size + int64(attachSize)
|
||||
}
|
||||
|
||||
mail.SetAttachments(atts)
|
||||
|
||||
return mail, MailInfo(mail), nil
|
||||
return mail, MailInfo(mail, size), nil
|
||||
}
|
||||
|
||||
// EnumerateContainers iterates through all of the users current
|
||||
@ -419,7 +436,7 @@ func (c Mail) Serialize(
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func MailInfo(msg models.Messageable) *details.ExchangeInfo {
|
||||
func MailInfo(msg models.Messageable, size int64) *details.ExchangeInfo {
|
||||
var (
|
||||
sender = UnwrapEmailAddress(msg.GetSender())
|
||||
subject = ptr.Val(msg.GetSubject())
|
||||
@ -444,6 +461,7 @@ func MailInfo(msg models.Messageable) *details.ExchangeInfo {
|
||||
Recipient: recipients,
|
||||
Subject: subject,
|
||||
Received: received,
|
||||
Size: size,
|
||||
Created: created,
|
||||
Modified: ptr.OrNow(msg.GetLastModifiedDateTime()),
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ func (suite *MailAPIUnitSuite) TestMailInfo() {
|
||||
for _, tt := range tests {
|
||||
suite.Run(tt.name, func() {
|
||||
msg, expected := tt.msgAndRP()
|
||||
assert.Equal(suite.T(), expected, api.MailInfo(msg))
|
||||
assert.Equal(suite.T(), expected, api.MailInfo(msg, 0))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +260,12 @@ func (col *Collection) streamItems(ctx context.Context, errs *fault.Bus) {
|
||||
return
|
||||
}
|
||||
|
||||
info.Size = int64(len(data))
|
||||
// In case of mail the size of data is calc as- size of body content+size of attachment
|
||||
// in all other case the size is - total item's serialized size
|
||||
if info.Size <= 0 {
|
||||
info.Size = int64(len(data))
|
||||
}
|
||||
|
||||
info.ParentPath = col.locationPath.String()
|
||||
|
||||
col.data <- &Stream{
|
||||
|
||||
@ -218,8 +218,7 @@ func RestoreMailMessage(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := api.MailInfo(clone)
|
||||
info.Size = int64(len(bits))
|
||||
info := api.MailInfo(clone, int64(len(bits)))
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user