mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-09-01 16:48:27 +00:00
Update for MPS 0.9.1.
This commit is contained in:
@@ -82,7 +82,10 @@ export class FirstMessageIsImageProtection extends AbstractProtection implements
|
||||
const roomID = room.toRoomIDOrAlias();
|
||||
if (!this.justJoined[roomID]) this.justJoined[roomID] = [];
|
||||
if (Value.Check(RoomMessage, event)) {
|
||||
const msgtype = event.content?.['msgtype'] || 'm.text';
|
||||
if (!('msgtype' in event.content)) {
|
||||
return Ok(undefined);
|
||||
}
|
||||
const msgtype = event.content['msgtype'] || 'm.text';
|
||||
const formattedBody = event.content !== undefined && 'formatted_body' in event.content ? event.content?.['formatted_body'] || '' : '';
|
||||
const isMedia = msgtype === 'm.image' || msgtype === 'm.video' || formattedBody.toLowerCase().includes('<img');
|
||||
if (isMedia && this.justJoined[roomID].includes(event['sender'])) {
|
||||
|
||||
@@ -64,6 +64,9 @@ export class MessageIsMediaProtection extends AbstractProtection implements Prot
|
||||
|
||||
public async handleTimelineEvent(room: MatrixRoomID, event: RoomEvent): Promise<ActionResult<void>> {
|
||||
if (Value.Check(RoomMessage, event)) {
|
||||
if (!('msgtype' in event.content)) {
|
||||
return Ok(undefined);
|
||||
}
|
||||
const msgtype = event.content?.['msgtype'] || 'm.text';
|
||||
const formattedBody = event.content !== undefined && 'formatted_body' in event.content ? event.content?.['formatted_body'] || '' : '';
|
||||
const isMedia = msgtype === 'm.image' || msgtype === 'm.video' || formattedBody.toLowerCase().includes('<img');
|
||||
|
||||
@@ -63,7 +63,7 @@ export class MessageIsVoiceProtection extends AbstractProtection implements Prot
|
||||
public async handleTimelineEvent(room: MatrixRoomID, event: RoomEvent): Promise<ActionResult<void>> {
|
||||
const roomID = room.toRoomIDOrAlias();
|
||||
if (Value.Check(RoomMessage, event)) {
|
||||
if (event.content?.msgtype !== 'm.audio') {
|
||||
if (!('msgtype' in event.content) || event.content?.msgtype !== 'm.audio') {
|
||||
return Ok(undefined);
|
||||
}
|
||||
await this.draupnir.managementRoomOutput.logMessage(LogLevel.INFO, "MessageIsVoice", `Redacting event from ${event['sender']} for posting a voice message. ${Permalinks.forEvent(roomID, event['event_id'], [serverName(this.draupnir.clientUserID)])}`);
|
||||
|
||||
@@ -88,6 +88,9 @@ export class WordListProtection extends AbstractProtection implements Protection
|
||||
public async handleTimelineEvent(room: MatrixRoomID, event: RoomEvent): Promise<ActionResult<void>> {
|
||||
const minsBeforeTrusting = this.draupnir.config.protections.wordlist.minutesBeforeTrusting;
|
||||
if (Value.Check(RoomMessage, event)) {
|
||||
if (!('msgtype' in event.content)) {
|
||||
return Ok(undefined);
|
||||
}
|
||||
const message = (event.content !== undefined && 'formatted_body' in event.content && event.content?.['formatted_body']) || event.content?.['body'];
|
||||
if (!message === undefined) {
|
||||
return Ok(undefined);
|
||||
|
||||
Reference in New Issue
Block a user