Merge pull request #11209 from annando/issue-10365-Events
Issue 10365: Event updates are now processed
This commit is contained in:
commit
121e40357c
|
@ -1428,6 +1428,17 @@ class Item
|
||||||
private static function storeForUser(array $item, int $uid)
|
private static function storeForUser(array $item, int $uid)
|
||||||
{
|
{
|
||||||
if (Post::exists(['uri-id' => $item['uri-id'], 'uid' => $uid])) {
|
if (Post::exists(['uri-id' => $item['uri-id'], 'uid' => $uid])) {
|
||||||
|
if (!empty($item['event-id'])) {
|
||||||
|
$post = Post::selectFirst(['event-id'], ['uri-id' => $item['uri-id'], 'uid' => $uid]);
|
||||||
|
if (!empty($post['event-id'])) {
|
||||||
|
$event = DBA::selectFirst('event', ['edited', 'start', 'finish', 'summary', 'desc', 'location', 'nofinish', 'adjust'], ['id' => $item['event-id']]);
|
||||||
|
if (!empty($event)) {
|
||||||
|
// We aren't using "Event::store" here, since we don't want to trigger any further action
|
||||||
|
$ret = DBA::update('event', $event, ['id' => $post['event-id']]);
|
||||||
|
Logger::info('Event updated', ['uid' => $uid, 'source-event' => $item['event-id'], 'target-event' => $post['event-id'], 'ret' => $ret]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Logger::info('Item already exists', ['uri-id' => $item['uri-id'], 'uid' => $uid]);
|
Logger::info('Item already exists', ['uri-id' => $item['uri-id'], 'uid' => $uid]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,6 +180,35 @@ class Processor
|
||||||
}
|
}
|
||||||
|
|
||||||
Item::update($item, ['uri' => $activity['id']]);
|
Item::update($item, ['uri' => $activity['id']]);
|
||||||
|
|
||||||
|
if ($activity['object_type'] == 'as:Event') {
|
||||||
|
$posts = Post::select(['event-id', 'uid'], ["`uri` = ? AND `event-id` > ?", $activity['id'], 0]);
|
||||||
|
while ($post = DBA::fetch($posts)) {
|
||||||
|
self::updateEvent($post['event-id'], $activity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update an existing event
|
||||||
|
*
|
||||||
|
* @param int $event_id
|
||||||
|
* @param array $activity
|
||||||
|
*/
|
||||||
|
private static function updateEvent(int $event_id, array $activity)
|
||||||
|
{
|
||||||
|
$event = DBA::selectFirst('event', [], ['id' => $event_id]);
|
||||||
|
|
||||||
|
$event['edited'] = DateTimeFormat::utc($activity['updated']);
|
||||||
|
$event['summary'] = HTML::toBBCode($activity['name']);
|
||||||
|
$event['desc'] = HTML::toBBCode($activity['content']);
|
||||||
|
$event['start'] = $activity['start-time'];
|
||||||
|
$event['finish'] = $activity['end-time'];
|
||||||
|
$event['nofinish'] = empty($event['finish']);
|
||||||
|
$event['location'] = $activity['location'];
|
||||||
|
|
||||||
|
Logger::info('Updating event', ['uri' => $activity['id'], 'id' => $event_id]);
|
||||||
|
Event::store($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user