Example #1
0
function onSubscribe($ev)
{
    global $users;
    global $chans;
    $event = $ev->GetValue("sip_event");
    $accept = $ev->GetValue("sip_accept");
    if ($event == "message-summary" && $accept == "application/simple-message-summary") {
        $s = new MailSub($ev);
        $s->AddTo($users);
        Yate::Debug("New mail subscription for " . $s->match);
    } else {
        if ($event == "dialog" && $accept == "application/dialog-info+xml") {
            $s = new DialogSub($ev);
            $s->AddTo($chans);
            Yate::Debug("New dialog subscription for " . $s->match);
        } else {
            return false;
        }
    }
    $s->Update($ev, false);
    $s->Flush();
    return true;
}
Example #2
0
function onSubscribe($ev)
{
    global $users;
    global $chans;
    global $pres;
    $event = $ev->GetValue("sip_event");
    $accept = $ev->GetValue("sip_accept");
    if ($event == "message-summary" && ($accept == "application/simple-message-summary" || $accept == "")) {
        $s = new MailSub($ev);
        $s->AddTo($users);
        Yate::Debug("New mail subscription for " . $s->match);
    } else {
        if ($event == "dialog" && ($accept == "application/dialog-info+xml" || $accept == "")) {
            $s = new DialogSub($ev);
            $s->AddTo($chans);
            Yate::Debug("New dialog subscription for " . $s->match);
        } else {
            if ($event == "presence" && ($accept == "application/pidf+xml" || $accept == "")) {
                $s = new PresenceSub($ev);
                $s->AddTo($pres);
                Yate::Debug("New presence subscription for " . $s->match);
            } else {
                return false;
            }
        }
    }
    $s->Update($ev, false);
    $s->Flush();
    // Return expires in OK
    $exp = $s->expire - time();
    if ($exp < 0) {
        $exp = 0;
    }
    $ev->params["osip_Expires"] = strval($exp);
    return true;
}