+ public function saveNoticeFromActivity(Activity $activity, Profile $actor, array $options=array())
+ {
+ // Any plugin which has not implemented saveObjectFromActivity _must_
+ // override this function until they are migrated (this function will
+ // be deleted when all plugins are migrated to saveObjectFromActivity).
+
+ if (isset($this->oldSaveNew)) {
+ throw new ServerException('A function has been called for new saveActivity functionality, but is still set with an oldSaveNew configuration');
+ }
+
+ return Notice::saveActivity($activity, $actor, $options);
+ }
+
+ /**
+ * Given a parsed ActivityStreams activity, your plugin gets
+ * to figure out itself how to store the additional data into
+ * the database, besides the base data stored by the core.
+ *
+ * This will handle just about all events where an activity
+ * object gets saved, whether it is via AtomPub, OStatus
+ * (PuSH and Salmon transports), or ActivityStreams-based
+ * backup/restore of account data.
+ *
+ * You should be able to accept as input the output from an
+ * asActivity() call on the stored object. Where applicable,
+ * try to use existing ActivityStreams structures and object
+ * types, and be liberal in accepting input from what might
+ * be other compatible apps.
+ *
+ * All micro-app classes must override this method.
+ *
+ * @fixme are there any standard options?
+ *
+ * @param Activity $activity
+ * @param Profile $actor
+ * @param array $options=array()
+ *
+ * @return Notice the resulting notice
+ */
+ protected function saveObjectFromActivity(Activity $activity, Notice $stored, array $options=array())
+ {
+ throw new ServerException('This function should be abstract when all plugins have migrated to saveObjectFromActivity');
+ }
+
+ /*
+ * This usually gets called from Notice::saveActivity after a Notice object has been created,
+ * so it contains a proper id and a uri for the object to be saved.
+ */
+ public function onStoreActivityObject(Activity $act, Notice $stored, array $options=array(), &$object) {
+ // $this->oldSaveNew is there during a migration period of plugins, to start using
+ // Notice::saveActivity instead of Notice::saveNew
+ if (!$this->isMyActivity($act) || isset($this->oldSaveNew)) {
+ return true;
+ }
+ $object = $this->saveObjectFromActivity($act, $stored, $options);
+ try {
+ $act->context->attention = array_merge($act->context->attention, $object->getAttentionArray());
+ } catch (Exception $e) {
+ common_debug('WARNING: Could not get attention list from object '.get_class($object).'!');
+ }
+ return false;
+ }