Skip to content

Commit

Permalink
new option
Browse files Browse the repository at this point in the history
  • Loading branch information
EsdrasCaleb committed Jan 25, 2024
1 parent 1baf301 commit 3b51e04
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 6 additions & 5 deletions classes/task/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ public function execute() {
}
}
}

$sql = "SELECT c.id,count(ua.id) as usuarios_deletado,count(DISTINCT m.id) as mensagens FROM {message_conversations} c
if($configs->cleanmessage) {
$sql = "SELECT c.id,count(ua.id) as usuarios_deletado,count(DISTINCT m.id) as mensagens FROM {message_conversations} c
JOIN {messages} m on m.conversationid =c.id
and c.type=?
JOIN {message_user_actions} ua on ua.messageid=m.id
and ua.action=?
GROUP BY c.id
HAVING count(ua.id) >=2*count(DISTINCT m.id)";
$deletedconversation = $DB->get_records_sql($sql, [$individualmessage, $delteaction]);
foreach ($deletedconversation as $conversation) {
\core_message\api::delete_all_conversation_data($conversation->id);
$deletedconversation = $DB->get_records_sql($sql, [$individualmessage, $delteaction]);
foreach ($deletedconversation as $conversation) {
\core_message\api::delete_all_conversation_data($conversation->id);
}
}
}
}
2 changes: 2 additions & 0 deletions lang/en/tool_deletemessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
$string['privacy:metadata'] = 'The local aws plugin does not store any personal data. However, it send the IP of a user that had an error to the sentry server configured in it.';
$string['harddelete'] = "Hard Delete Messages";
$string['harddelete_desc'] = "All Deleted messages by this plugin will be deleted from database";
$string['cleanmessage'] = "Clear Conversations";
$string['cleanmessage_desc'] = "When Both user delete all messages between them the messages will be erased from database";
4 changes: 4 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
get_string('harddelete', 'tool_deletemessage'),
get_string('harddelete_desc', 'tool_deletemessage'), $default));

$page->add(new admin_setting_configcheckbox('tool_deletemessage/cleanmessage',
get_string('cleanmessage', 'tool_deletemessage'),
get_string('cleanmessage_desc', 'tool_deletemessage'), $default));

$ADMIN->add('messaging', $page);

}
Expand Down

0 comments on commit 3b51e04

Please sign in to comment.