mirror of
https://github.com/Thumbscrew/PSMatrix.git
synced 2025-04-12 02:03:39 +00:00
39 lines
897 B
PowerShell
39 lines
897 B
PowerShell
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 $_
|
|
}
|
|
} |