add matrix_room_untag.ps1
parent
d56fdeac6c
commit
0610b1478d
@ -0,0 +1,31 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Array]$Exceptions = @('m.lowpriority','m.favourite'),
|
||||||
|
[String]$HomeServer = 'https://imninja.net',
|
||||||
|
[String]$MxId = '@lub:imninja.net',
|
||||||
|
[String]$AccessToken
|
||||||
|
)
|
||||||
|
|
||||||
|
function Invoke-MatrixMethod {
|
||||||
|
Param (
|
||||||
|
$Method = 'Get',
|
||||||
|
$Endpoint
|
||||||
|
)
|
||||||
|
|
||||||
|
# add authorization header
|
||||||
|
$Headers = $Headers+@{'authorization' = 'Bearer '+$AccessToken}
|
||||||
|
|
||||||
|
$uri = $HomeServer+$Endpoint
|
||||||
|
|
||||||
|
Invoke-RestMethod -Method $Method -Headers $Headers -Uri $uri
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($room in (Invoke-MatrixMethod -Endpoint '/_matrix/client/r0/joined_rooms').joined_rooms) {
|
||||||
|
foreach($tag in (Invoke-MatrixMethod -Endpoint ('/_matrix/client/r0/user/'+$MxId+'/rooms/'+$room+'/tags')).tags) {
|
||||||
|
$tag = ($tag | Get-Member)[4].Name
|
||||||
|
if($tag -and $tag -notin $Exceptions) {
|
||||||
|
'delete '+$tag
|
||||||
|
Invoke-MatrixMethod -Method Delete -Endpoint ('/_matrix/client/r0/user/'+$MxId+'/rooms/'+$room+'/tags/'+$tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue