summaryrefslogtreecommitdiff
path: root/scripts/maildaemon.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2008-10-04 12:32:13 -0400
committerEvan Prodromou <evan@controlyourself.ca>2008-10-04 12:32:13 -0400
commitf072147e4e538b6851e3056fe9ff84952424c828 (patch)
tree0a35402e891208adc504d129102fc4527afb1b1e /scripts/maildaemon.php
parentc8fd8fa00f30cb2862a6feb32bc1b7d3a394c565 (diff)
add channels and use command interpreter in different channels
darcs-hash:20081004163213-5ed1f-684ecb464e843b1bbe456c348e56b40a39a83ecd.gz
Diffstat (limited to 'scripts/maildaemon.php')
-rwxr-xr-xscripts/maildaemon.php30
1 files changed, 7 insertions, 23 deletions
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php
index 3d3b30951..db283c4a0 100755
--- a/scripts/maildaemon.php
+++ b/scripts/maildaemon.php
@@ -58,9 +58,8 @@ class MailerDaemon {
$this->error($from, _('Sorry, no incoming email allowed.'));
return false;
}
- $response = $this->handle_command($user, $msg);
+ $response = $this->handle_command($user, $from, $msg);
if ($response) {
- $this->respond($from, $to, $response);
return true;
}
$msg = $this->cleanup_msg($msg);
@@ -97,31 +96,16 @@ class MailerDaemon {
return false;
}
- function handle_command($user, $msg) {
- $cmd = trim(strtolower($msg));
- switch ($cmd) {
- case 'off':
- $this->set_notify($user, false);
+ function handle_command($user, $from, $msg) {
+ $inter = new CommandInterpreter();
+ $cmd = $inter->handle_command($user, $msg);
+ if ($cmd) {
+ $cmd->execute(new MailChannel($from));
return true;
- case 'on':
- $this->set_notify($user, true);
- return true;
- default:
- return false;
}
+ return false;
}
- function set_notify($user, $value) {
- $orig = clone($user);
- $user->smsnotify = $value;
- $result = $user->update($orig);
- if (!$result) {
- common_log_db_error($user, 'UPDATE', __FILE__);
- return false;
- }
- return true;
- }
-
function respond($from, $to, $response) {
$headers['From'] = $to;