add Remove-MatrixRoomMessage

This commit is contained in:
2022-04-05 17:07:46 +01:00
parent 76bc3aa63f
commit 9c7d12107b
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,39 @@
function Remove-MatrixRoomMessage {
param (
[Parameter(Mandatory)]
[string]
$ServerUrl,
[Parameter(Mandatory)]
[SecureString]
$AccessToken,
[Parameter(Mandatory)]
[string]
$RoomId,
[Parameter(Mandatory)]
[MatrixMessage]
$Message,
[Parameter(Mandatory=$false)]
[string]
$Reason
)
$eventId = $Message.EventID
$txnId = New-Guid
$url = New-MatrixUrl -ServerUrl $ServerUrl -ApiPath "_matrix/client/v3/rooms/$RoomId/redact/$eventId/$txnId"
Write-Debug "URL: $url"
$method = "Put"
$headers = Get-MatrixAuthHeaders -AccessToken $AccessToken
$body = @{
reason = $Reason
} | ConvertTo-Json
try {
return Invoke-RestMethod -Uri $url -Method $method -Headers $headers -Body $body
} catch {
Write-Error $_
}
}