From d9b959fc64e4e36b0957afd33482f480b24868f9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 4 Aug 2010 12:07:49 -0700 Subject: move code for making activities from OStatus plugin to Subscription and Fave classes --- classes/Fave.php | 25 +++++++++++++++++++++++++ classes/Subscription.php | 26 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) (limited to 'classes') diff --git a/classes/Fave.php b/classes/Fave.php index ed4f56aee..9d0b0aa02 100644 --- a/classes/Fave.php +++ b/classes/Fave.php @@ -129,4 +129,29 @@ class Fave extends Memcached_DataObject return $ids; } + + function asActivity() + { + $notice = Notice::staticGet('id', $this->notice_id); + $profile = Profile::staticGet('id', $this->user_id); + + $act = new Activity(); + + $act->verb = ActivityVerb::FAVORITE; + $act->id = TagURI::mint('favor:%d:%d:%s', + $profile->id, + $notice->id, + common_date_iso8601($this->created)); + + $act->time = $this->created; + $act->title = _("Favor"); + $act->content = sprintf(_("%s marked notice %s as a favorite."), + $profile->getBestName(), + $notice->uri); + + $act->actor = ActivityObject::fromProfile($profile); + $act->object = ActivityObject::fromNotice($notice); + + return $act; + } } diff --git a/classes/Subscription.php b/classes/Subscription.php index 0225ed4df..0044699a3 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -235,4 +235,30 @@ class Subscription extends Memcached_DataObject 'subscribed' => $other->id)); return (empty($sub)) ? false : true; } + + function asActivity() + { + $subscriber = Profile::staticGet('id', $this->subscriber); + $subscribed = Profile::staticGet('id', $this->subscribed); + + $act = new Activity(); + + $act->verb = ActivityVerb::FOLLOW; + + $act->id = TagURI::mint('follow:%d:%d:%s', + $subscriber->id, + $subscribed->id, + common_date_iso8601($this->created)); + + $act->time = strtotime($this->created); + $act->title = _("Follow"); + $act->content = sprintf(_("%s is now following %s."), + $subscriber->getBestName(), + $subscribed->getBestName()); + + $act->actor = ActivityObject::fromProfile($subscriber); + $act->object = ActivityObject::fromProfile($subscribed); + + return $act; + } } -- cgit v1.2.3-54-g00ecf