Permalink
Browse files

post "op" messages to the user's messages queue

  • Loading branch information...
1 parent 4f3aff2 commit b4d0ef8371829f7f5f5ee02d7ce267a871dafcc4 @kerphi committed Jan 13, 2013
Showing with 9 additions and 5 deletions.
  1. +4 −2 server/container/channels-op.php
  2. +1 −1 server/container/messages.php
  3. +4 −2 server/routes/channels-op.php
@@ -19,7 +19,8 @@ static public function getOpList($cid) {
static public function addOp($cid, $uid) {
$cdir = Container_channels::getChannelsDir();
$p = $cdir.'/'.$cid.'/op/'.$uid;
- return @touch($p);
+ @touch($p);
+ return file_exists($p);
}
/**
@@ -28,7 +29,8 @@ static public function addOp($cid, $uid) {
static public function rmOp($cid, $uid) {
$cdir = Container_channels::getChannelsDir();
$p = $cdir.'/'.$cid.'/op/'.$uid;
- return @unlink($p);
+ @unlink($p);
+ return !file_exists($p);
}
/**
@@ -34,7 +34,7 @@ static public function postMsgToChannel($cid, $uid, $body, $type = 'msg') {
foreach (Container_channels::getChannelUsers($cid) as $subuid) {
// post this message on each users subscribed on the channel
// /users/:uid/msg/
- if ($subuid != $uid) { // don't post message to the current connected user
+ if ($subuid != $uid) { // don't post message to the sender
$umdir = Container_users::getDir().'/'.$subuid.'/messages';
file_put_contents($umdir.'/'.$mid, $msg);
}
@@ -103,7 +103,8 @@
$ok = Container_channels_op::addOp($cid, $uid);
if ($ok) {
$res->status(200);
- // todo: notification to other connected user of this new operator
+ // notification to other connected user of this new operator
+ Container_messages::postMsgToChannel($cid, $online_uid, $uid, 'op');
} else {
$res->status(500);
}
@@ -141,7 +142,8 @@
$ok = Container_channels_op::rmOp($cid, $uid);
if ($ok) {
$res->status(200);
- // todo: notification to other connected user of this removed operator
+ // notification to other connected user of this removed operator
+ Container_messages::postMsgToChannel($cid, $online_uid, $uid, 'deop');
} else {
$res->status(500);
}

0 comments on commit b4d0ef8

Please sign in to comment.