Support for message delivering via uri-id
This commit is contained in:
parent
07c07ec499
commit
6e1483545e
10 changed files with 95 additions and 56 deletions
|
@ -173,32 +173,32 @@ class Event
|
|||
{
|
||||
$ev = [];
|
||||
|
||||
$match = '';
|
||||
$match = [];
|
||||
if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $text, $match)) {
|
||||
$ev['summary'] = $match[1];
|
||||
}
|
||||
|
||||
$match = '';
|
||||
$match = [];
|
||||
if (preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is", $text, $match)) {
|
||||
$ev['desc'] = $match[1];
|
||||
}
|
||||
|
||||
$match = '';
|
||||
$match = [];
|
||||
if (preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is", $text, $match)) {
|
||||
$ev['start'] = $match[1];
|
||||
}
|
||||
|
||||
$match = '';
|
||||
$match = [];
|
||||
if (preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is", $text, $match)) {
|
||||
$ev['finish'] = $match[1];
|
||||
}
|
||||
|
||||
$match = '';
|
||||
$match = [];
|
||||
if (preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is", $text, $match)) {
|
||||
$ev['location'] = $match[1];
|
||||
}
|
||||
|
||||
$match = '';
|
||||
$match = [];
|
||||
if (preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is", $text, $match)) {
|
||||
$ev['adjust'] = $match[1];
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ class Event
|
|||
|
||||
DBA::update('event', $updated_fields, ['id' => $event['id'], 'uid' => $event['uid']]);
|
||||
|
||||
$item = Post::selectFirst(['id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
|
||||
$item = Post::selectFirst(['id', 'uri-id'], ['event-id' => $event['id'], 'uid' => $event['uid']]);
|
||||
if (DBA::isResult($item)) {
|
||||
$object = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$object .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||
|
@ -339,9 +339,9 @@ class Event
|
|||
$fields = ['body' => self::getBBCode($event), 'object' => $object, 'edited' => $event['edited']];
|
||||
Item::update($fields, ['id' => $item['id']]);
|
||||
|
||||
$item_id = $item['id'];
|
||||
$uriid = $item['uri-id'];
|
||||
} else {
|
||||
$item_id = 0;
|
||||
$uriid = 0;
|
||||
}
|
||||
|
||||
Hook::callAll('event_updated', $event['id']);
|
||||
|
@ -349,7 +349,7 @@ class Event
|
|||
// New event. Store it.
|
||||
DBA::insert('event', $event);
|
||||
|
||||
$item_id = 0;
|
||||
$uriid = 0;
|
||||
|
||||
// Don't create an item for birthday events
|
||||
if ($event['type'] == 'event') {
|
||||
|
@ -360,6 +360,7 @@ class Event
|
|||
$item_arr['uid'] = $event['uid'];
|
||||
$item_arr['contact-id'] = $event['cid'];
|
||||
$item_arr['uri'] = $event['uri'];
|
||||
$item_arr['uri-id'] = ItemURI::getIdByURI($event['uri']);
|
||||
$item_arr['guid'] = $event['guid'];
|
||||
$item_arr['plink'] = $arr['plink'] ?? '';
|
||||
$item_arr['post-type'] = Item::PT_EVENT;
|
||||
|
@ -392,13 +393,15 @@ class Event
|
|||
$item_arr['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||
$item_arr['object'] .= '</object>' . "\n";
|
||||
|
||||
$item_id = Item::insert($item_arr);
|
||||
if (Item::insert($item_arr)) {
|
||||
$uriid = $item_arr['uri-id'];
|
||||
}
|
||||
}
|
||||
|
||||
Hook::callAll("event_created", $event['id']);
|
||||
}
|
||||
|
||||
return $item_id;
|
||||
return $uriid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -212,7 +212,8 @@ class Item
|
|||
DBA::close($items);
|
||||
|
||||
foreach ($notify_items as $notify_item) {
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, $notify_item);
|
||||
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $notify_item]);
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
|
||||
}
|
||||
|
||||
return $rows;
|
||||
|
@ -354,7 +355,7 @@ class Item
|
|||
|
||||
// send the notification upstream/downstream
|
||||
if ($priority) {
|
||||
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, intval($item['id']));
|
||||
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, (int)$item['uri-id'], (int)$item['uid']);
|
||||
}
|
||||
} elseif ($item['uid'] != 0) {
|
||||
Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]);
|
||||
|
@ -1142,7 +1143,7 @@ class Item
|
|||
}
|
||||
|
||||
if ($transmit) {
|
||||
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, $current_post);
|
||||
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $notify_type, (int)$item['uri-id'], (int)$item['uid']);
|
||||
}
|
||||
|
||||
return $current_post;
|
||||
|
@ -1866,7 +1867,7 @@ class Item
|
|||
'owner-id' => $owner_id, 'private' => $private, 'psid' => $psid];
|
||||
self::update($fields, ['id' => $item_id]);
|
||||
|
||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', Delivery::POST, $item_id);
|
||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', Delivery::POST, (int)$item['uri-id'], (int)$item['uid']);
|
||||
|
||||
self::performActivity($item_id, 'announce', $uid);
|
||||
|
||||
|
|
|
@ -246,13 +246,7 @@ class Post
|
|||
*/
|
||||
public static function select(array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
$timestamp = microtime(true);
|
||||
$data = self::selectView('post-view', $selected, $condition, $params);
|
||||
|
||||
$duration = microtime(true) - $timestamp;;
|
||||
if ($duration > 0.1)
|
||||
Logger::info('Blubb', ['duration' => $duration, 'selected' => $selected, 'condition' => $condition, 'params' => $params, 'callstack' => System::callstack(20)]);
|
||||
return $data;
|
||||
return self::selectView('post-view', $selected, $condition, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -335,7 +329,6 @@ class Post
|
|||
*/
|
||||
public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
//Logger::info('Blubb', ['uid' => $uid, 'selected' => $selected, 'condition' => $condition, 'params' => $params]);
|
||||
return self::selectViewForUser('post-view', $uid, $selected, $condition, $params);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue