function friendlyui_user_new(&$entityDS, &$userDS) { // create a welcome message for the new user's stream $welcome = new HubbubMessage('notice'); $welcome->owner($entityDS); $welcome->data['notice_type'] = 'welcome'; $welcome->save(); }
function makePostMessage($type, $post) { // note/todo: if this works correctly, we should see a duplicate message if we're posting on someone else's profile $msg = new HubbubMessage($type); foreach($post as $k => $v) $msg->data[$k] = $v; $msg->save(); WriteToFile('log/activity.log', $type.' created: '.$msg->data['msgid'].chr(10)); return($msg); }
function foreign_post_receive(&$data, &$msg) { if (!$msg->validateSignature()) { return true; } WriteToFile('log/activity.log', $data['msgid'] . ' foreign_post ' . $msg->ownerEntity->key() . ' to ' . $msg->authorEntity->key() . chr(10)); $con = new HubbubConnection($msg->ownerEntity->key(), $msg->authorEntity->key()); if ($con->status() != 'friend') { return $msg->fail('no connection'); } $usr = new HubbubUser($msg->ownerEntity->key()); if ($con->ds['c_auto_approve'] == 'Y') { // if we're gonna approve this anyway, there is no reason to store the message // let's just create a post out of this WriteToFile('log/activity.log', $data['msgid'] . ' foreign_post received, accepted' . chr(10)); $post = new HubbubMessage('post'); $npid = $post->data['msgid']; $post->data = $msg->data; $post->data['type'] = 'post'; $post->data['msgid'] = $npid; $post->author($msg->authorEntity->ds); $post->owner($msg->ownerEntity->ds); $post->data['changed'] = time(); $post->data['received'] = time(); $post->data['rel']['foreign'] = $data['msgid']; $post->save(); WriteToFile('log/activity.log', $post->data['msgid'] . ' created from foreign_post' . chr(10)); $msg->response['post'] = $post->data; $msg->doSave = false; $usr->notify('fpost/new', $msg->authorEntity, $msg); } else { // if not, let's store this message for later approval $usr->notify('fpost/approve', $msg->authorEntity, $msg); $msg->vTag = 'A'; $msg->save(); } $msg->ok(); }
$streamPosts1 = $this->msg->getStream($ne2->key()); $wallPosts1 = $this->msg->getPostList($ne1->key()); $postFound9 = -1; $postFound10 = -1; foreach($streamPosts1['list'] as $pds) if($pds['m_id'] == $post->data['msgid']) $postFound9 = $pds['m_id']; tlog($postFound9 == -1, 'Message gone from author stream', 'OK', 'fail (#'.$postFound9.')'); foreach($wallPosts1['list'] as $pds) if($pds['m_id'] == $post->data['msgid']) $postFound10 = $pds['m_id']; tlog($postFound10 == -1, 'Message gone from owner profile', 'OK', 'fail ('.$postFound10.')'); $post = new HubbubMessage('post'); $post->localUserEntity = $ne2->key(); $post->author($ne2->ds); $post->owner($ne1->ds); $post->data['text'] = 'This is a message, it will be deleted. Umlauts like üöä should be preserved.'; $post->save(); $post->executeHandler('delete'); tlog($post->data['deleted'] == 'yes', 'Author: "deleted" property set', 'OK', 'fail'); tlog($post->isDeleted, '"deleted" internal property set', 'OK', 'fail'); $streamPosts1 = $this->msg->getStream($ne2->key()); $wallPosts1 = $this->msg->getPostList($ne1->key()); $postFound9 = -1; $postFound10 = -1; foreach($streamPosts1['list'] as $pds) if($pds['m_id'] == $post->data['msgid']) $postFound9 = $pds['m_id']; tlog($postFound9 == -1, 'Message gone from author stream', 'OK', 'fail (#'.$postFound9.')'); foreach($wallPosts1['list'] as $pds) if($pds['m_id'] == $post->data['msgid']) $postFound10 = $pds['m_id']; tlog($postFound10 == -1, 'Message gone from owner profile', 'OK', 'fail ('.$postFound10.')'); // next, we'll try an invalid update where the author has suddenly changed