move code for making activities from OStatus plugin to Subscription and Fave classes
This commit is contained in:
parent
9aadd3cb42
commit
d9b959fc64
@ -129,4 +129,29 @@ class Fave extends Memcached_DataObject
|
|||||||
|
|
||||||
return $ids;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,4 +235,30 @@ class Subscription extends Memcached_DataObject
|
|||||||
'subscribed' => $other->id));
|
'subscribed' => $other->id));
|
||||||
return (empty($sub)) ? false : true;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,25 +553,10 @@ class OStatusPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$act = new Activity();
|
$sub = Subscription::pkeyGet(array('subscriber' => $subscriber->id,
|
||||||
|
'subscribed' => $other->id));
|
||||||
|
|
||||||
$act->verb = ActivityVerb::FOLLOW;
|
$act = $sub->asActivity();
|
||||||
|
|
||||||
$act->id = TagURI::mint('follow:%d:%d:%s',
|
|
||||||
$subscriber->id,
|
|
||||||
$other->id,
|
|
||||||
common_date_iso8601(time()));
|
|
||||||
|
|
||||||
$act->time = time();
|
|
||||||
$act->title = _("Follow");
|
|
||||||
// TRANS: Success message for subscribe to user attempt through OStatus.
|
|
||||||
// TRANS: %1$s is the subscriber name, %2$s is the subscribed user's name.
|
|
||||||
$act->content = sprintf(_("%1$s is now following %2$s."),
|
|
||||||
$subscriber->getBestName(),
|
|
||||||
$other->getBestName());
|
|
||||||
|
|
||||||
$act->actor = ActivityObject::fromProfile($subscriber);
|
|
||||||
$act->object = ActivityObject::fromProfile($other);
|
|
||||||
|
|
||||||
$oprofile->notifyActivity($act, $subscriber);
|
$oprofile->notifyActivity($act, $subscriber);
|
||||||
|
|
||||||
@ -744,24 +729,15 @@ class OStatusPlugin extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$act = new Activity();
|
$fav = Fave::pkeyGet(array('user_id' => $user->id,
|
||||||
|
'notice_id' => $notice->id));
|
||||||
|
|
||||||
$act->verb = ActivityVerb::FAVORITE;
|
if (empty($fav)) {
|
||||||
$act->id = TagURI::mint('favor:%d:%d:%s',
|
// That's weird.
|
||||||
$profile->id,
|
return true;
|
||||||
$notice->id,
|
}
|
||||||
common_date_iso8601(time()));
|
|
||||||
|
|
||||||
$act->time = time();
|
$act = $fav->asActivity();
|
||||||
$act->title = _("Favor");
|
|
||||||
// TRANS: Success message for adding a favorite notice through OStatus.
|
|
||||||
// TRANS: %1$s is the favoring user's name, %2$s is URI to the favored notice.
|
|
||||||
$act->content = sprintf(_("%1$s marked notice %2$s as a favorite."),
|
|
||||||
$profile->getBestName(),
|
|
||||||
$notice->uri);
|
|
||||||
|
|
||||||
$act->actor = ActivityObject::fromProfile($profile);
|
|
||||||
$act->object = ActivityObject::fromNotice($notice);
|
|
||||||
|
|
||||||
$oprofile->notifyActivity($act, $profile);
|
$oprofile->notifyActivity($act, $profile);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user