+ static function fromNoticeSource(Notice_source $source)
+ {
+ $object = new ActivityObject();
+ $wellKnown = array('web', 'xmpp', 'mail', 'omb', 'system', 'api', 'ostatus',
+ 'activity', 'feed', 'mirror', 'twitter', 'facebook');
+
+ if (Event::handle('StartActivityObjectFromNoticeSource', array($source, &$object))) {
+ $object->type = ActivityObject::APPLICATION;
+
+ if (in_array($source->code, $wellKnown)) {
+ // We use one ID for all well-known StatusNet sources
+ $object->id = "tag:status.net,2009:notice-source:".$source->code;
+ } else if ($source->url) {
+ // They registered with an URL
+ $object->id = $source->url;
+ } else {
+ // Locally-registered, no URL
+ $object->id = TagURI::mint("notice-source:".$source->code);
+ }
+
+ if ($source->url) {
+ $object->link = $source->url;
+ }
+
+ if ($source->name) {
+ $object->title = $source->name;
+ } else {
+ $object->title = $source->code;
+ }
+
+ if ($source->created) {
+ $object->date = $source->created;
+ }
+
+ $object->extra[] = array('status_net', array('source_code' => $source->code));
+
+ Event::handle('EndActivityObjectFromNoticeSource', array($source, &$object));
+ }
+
+ return $object;
+ }
+
+ static function fromMessage(Message $message)
+ {
+ $object = new ActivityObject();
+
+ if (Event::handle('StartActivityObjectFromMessage', array($message, &$object))) {
+
+ $object->type = ActivityObject::NOTE;
+ $object->id = ($message->uri) ? $message->uri : (($message->url) ? $message->url : TagURI::mint(sprintf("message:%d", $message->id)));
+ $object->content = $message->rendered;
+ $object->date = $message->created;
+
+ if ($message->url) {
+ $object->link = $message->url;
+ } else {
+ $object->link = common_local_url('showmessage', array('message' => $message->id));
+ }
+
+ $object->extra[] = array('status_net', array('message_id' => $message->id));
+
+ Event::handle('EndActivityObjectFromMessage', array($message, &$object));
+ }
+
+ return $object;
+ }
+