mirror of
https://github.com/Thumbscrew/PSMatrix.git
synced 2025-04-12 02:03:39 +00:00
add Remove-MatrixRoomMessage
This commit is contained in:
parent
76bc3aa63f
commit
9c7d12107b
@ -77,7 +77,8 @@ FunctionsToExport = @(
|
|||||||
'Get-MatrixJoinedRooms',
|
'Get-MatrixJoinedRooms',
|
||||||
'Get-MatrixJoinedMembers',
|
'Get-MatrixJoinedMembers',
|
||||||
'Get-MatrixRoomId',
|
'Get-MatrixRoomId',
|
||||||
'Get-MatrixRoomMessages'
|
'Get-MatrixRoomMessages',
|
||||||
|
'Remove-MatrixRoomMessage'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
||||||
|
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 $_
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user