Skip to content

Commit 6feef99

Browse files
committed
Reduced usage of JSON properties
1 parent b8ccb19 commit 6feef99

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Slack.Backup/Private/backup/Invoke-ChannelBackup.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,24 @@ function Invoke-ChannelBackup {
2222
Write-Verbose "Get-ChannelNewMessages [$ChannelId][$(Convert-EpochToDate $Start)]"
2323
[array]$newMessages = Get-FullHistory -Token $Token -ChannelId $ChannelId -Start $start
2424

25-
$ids = $messages.client_msg_id
25+
$ids = $messages.ts
2626
$threadDeep = Convert-DateToEpoch (Get-Date).AddDays(-90)
27-
$threaded = $messages | ? { $_.reply_count -ne $null } | ? { [double]$_.ts -le $start -and [double]$_.ts -gt $threadDeep }
27+
$threaded = $messages | ? { $_.latest_reply -ne $null } | ? { [double]$_.ts -le $start -and [double]$_.ts -gt $threadDeep }
2828
$threaded | % {
2929
$om = $_
30-
$response = Get-Thread -Token $Token -ChannelId $ChannelId -ThreadTs $om.thread_ts
30+
$response = Get-Thread -Token $Token -ChannelId $ChannelId -ThreadTs $om.ts
3131
if ($response.ok -eq $true) {
3232
$replies = $response.messages
3333
$nm = $replies | Select-Object -First 1
3434
if ($nm -and ([double]$nm.latest_reply) -gt ([double]$om.latest_reply)) {
3535
Write-Verbose "Update parent message: $($om.client_msg_id)"
3636
$index = $messages.IndexOf($om)
37-
$messages.Item($index) = $nm
37+
$nmp = Invoke-MessageProcessingPipeline -SlackMessage $nm
38+
$messages.Item($index) = $nmp
3839

3940
$replies | Select-Object -Skip 1 | % {
4041
$m = $_
41-
if ($ids.Contains($m.client_msg_id) -eq $false) {
42+
if ($ids.Contains($m.ts) -eq $false) {
4243
Write-Verbose "Adding new thread meassage: $($m.client_msg_id)"
4344
$newMessages += $m
4445
}

0 commit comments

Comments
 (0)