' modified = "%s" '.
'WHERE user_id = %d '.
'AND notice_id = %d',
- Fave::newURI($fave->user_id, $fave->notice_id, $fave->modified),
+ Fave::newUri($fave->user_id, $fave->notice_id, $fave->modified),
common_sql_date(strtotime($fave->modified)),
$fave->user_id,
$fave->notice_id));
'format' => '(xml|json)'));
}
- public function saveNoticeFromActivity(Activity $activity, Profile $actor, array $options=array())
+ // FIXME: Set this to abstract public in lib/activityhandlerplugin.php ddwhen all plugins have migrated!
+ protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options=array())
{
+ assert($this->isMyActivity($act));
+
+ // If empty, we should've created it ourselves on our node.
+ if (!isset($options['created'])) {
+ $options['created'] = !empty($act->time) ? common_sql_date($act->time) : common_sql_now();
+ }
+ if (!isset($options['uri'])) {
+ $options['uri'] = !empty($act->id) ? $act->id : $act->selfLink;
+ }
+
+ // We must have an objects[0] here because in isMyActivity we require the count to be == 1
+ $actobj = $act->objects[0];
+
+ try {
+ $object = Fave::saveActivityObject($actobj, $stored);
+ } catch (ServerException $e) {
+ // Probably that the favored notice doesn't exist in our local database
+ // but may also be some missing profile or so, which we could catch in a
+ // more explicit catch-statement.
+ return null;
+ }
+ return $object;
}
+
public function activityObjectFromNotice(Notice $notice)
{
+ $fave = Fave::fromStored($notice);
+ return $fave->asActivityObject();
}
public function deleteRelated(Notice $notice)
{
+ try {
+ $fave = Fave::fromStored($notice);
+ $fave->delete();
+ } catch (NoResultException $e) {
+ // Cool, no problem. We wanted to get rid of it anyway.
+ }
}
// API stuff
{
parent::onNoticeDeleteRelated($notice);
- // The below algorithm is because we have faves not stored as
- // proper activities in Notice from legacy versions of SN/GNU social
+ // The below algorithm is because we want to delete fave
+ // activities on any notice which _has_ faves, and not as
+ // in the parent function only ones that _are_ faves.
$fave = new Fave();
$fave->notice_id = $notice->id;
if ($fave->find()) {
while ($fave->fetch()) {
- Fave::blowCacheForProfileId($fave->user_id);
$fave->delete();
}
}
}
}
+ public function showNoticeListItem(NoticeListItem $nli)
+ {
+ // pass
+ }
+ public function openNoticeListItemElement(NoticeListItem $nli)
+ {
+ // pass
+ }
+ public function closeNoticeListItemElement(NoticeListItem $nli)
+ {
+ // pass
+ }
+
public function onAppendUserActivityStreamObjects(UserActivityStream $uas, array &$objs)
{
$faves = array();