mirror of
https://github.com/Thumbscrew/PSMatrix.git
synced 2025-07-12 08:57:33 +00:00
add Remove-MatrixRoomMessage
This commit is contained in:
39
public/Remove-MatrixRoomMessage.ps1
Normal file
39
public/Remove-MatrixRoomMessage.ps1
Normal 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 $_
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user