Skip to content

Commit 704b5d8

Browse files
author
Luis Orta
committed
Stole the AT Filters
1 parent 86b9778 commit 704b5d8

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

CodersUnite/at.filters.ps1

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
function com.atproto.repo.listRecords {
2+
[CmdletBinding(SupportsPaging)]
3+
[Alias('at.records')]
4+
param(
5+
[Parameter(ValueFromPipelineByPropertyName)]
6+
[string]
7+
$did = "did:plc:hlchta7bwmobyum375ltycg5",
8+
9+
[Parameter(ValueFromPipelineByPropertyName)]
10+
[Alias('$type')]
11+
[string]
12+
$Collection = "app.bsky.feed.post",
13+
14+
[string]
15+
$Cursor,
16+
17+
[int]
18+
$Limit = 100
19+
)
20+
21+
process {
22+
$total = [long]0
23+
$skipped = [long]0
24+
:AtSync do {
25+
$xrpcUrl = "https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=$did&collection=$collection&cursor=$Cursor&limit=$Limit"
26+
$results = Invoke-RestMethod $xrpcUrl
27+
if ($results -and $results.cursor) {
28+
$Cursor = $results.cursor
29+
}
30+
foreach ($record in $results.records) {
31+
if ($PSCmdlet.PagingParameters.Skip -and
32+
$skipped -lt $PSCmdlet.PagingParameters.Skip
33+
) {
34+
$skipped++
35+
continue
36+
}
37+
38+
$record.pstypenames.insert(0, $collection)
39+
$record
40+
$total++
41+
42+
if ($PSCmdlet.PagingParameters.First -and
43+
$total -ge $PSCmdlet.PagingParameters.First) {
44+
break AtSync
45+
}
46+
}
47+
} while ($results -and $results.cursor)
48+
}
49+
50+
51+
}

0 commit comments

Comments
 (0)