We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 85528ccb authored by Brion Vibber's avatar Brion Vibber

Merge branch 'testing' of gitorious.org:statusnet/mainline into 0.9.x

parents 86f2f530 3e7a2a40
......@@ -729,3 +729,22 @@ StartGetProfileUri: When determining the canonical URI for a given profile
EndGetProfileUri: After determining the canonical URI for a given profile
- $profile: the current profile
- &$uri: the URI
StartFavorNotice: Saving a notice as a favorite
- $profile: profile of the person faving (can be remote!)
- $notice: notice being faved
- &$fave: Favor object; null to start off with, but feel free to override.
EndFavorNotice: After saving a notice as a favorite
- $profile: profile of the person faving (can be remote!)
- $notice: notice being faved
StartDisfavorNotice: Saving a notice as a favorite
- $profile: profile of the person faving (can be remote!)
- $notice: notice being faved
- &$result: result of the disfavoring (if you override)
EndDisfavorNotice: After saving a notice as a favorite
- $profile: profile of the person faving (can be remote!)
- $notice: notice being faved
......@@ -79,7 +79,7 @@ class ApiDirectMessageAction extends ApiAuthAction
}
$server = common_root_url();
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
if ($this->arg('sent')) {
......
......@@ -124,12 +124,9 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
return;
}
$result = subs_unsubscribe_user($this->user, $this->other->nickname);
if (is_string($result)) {
$this->clientError($result, 403, $this->format);
return;
}
// throws an exception on error
Subscription::cancel($this->user->getProfile(),
$this->other->getProfile());
$this->initDocument($this->format);
$this->showProfile($this->other, $this->format);
......
......@@ -93,7 +93,7 @@ class ApiGroupListAction extends ApiBareAuthAction
$sitename = common_config('site', 'name');
$title = sprintf(_("%s's groups"), $this->user->nickname);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:Groups";
$link = common_local_url(
'usergroups',
......
......@@ -88,7 +88,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
$sitename = common_config('site', 'name');
$title = sprintf(_("%s groups"), $sitename);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:Groups";
$link = common_local_url('groups');
$subtitle = sprintf(_("groups on %s"), $sitename);
......
......@@ -110,7 +110,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
$this->user->nickname
);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:Favorites:" . $this->user->id;
$subtitle = sprintf(
......
......@@ -112,7 +112,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(_("%s and friends"), $this->user->nickname);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:FriendsTimeline:" . $this->user->id;
$subtitle = sprintf(
......
......@@ -107,7 +107,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
$sitename = common_config('site', 'name');
$avatar = $this->group->homepage_logo;
$title = sprintf(_("%s timeline"), $this->group->nickname);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:GroupTimeline:" . $this->group->id;
$subtitle = sprintf(
......
......@@ -113,7 +113,7 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(_("%s and friends"), $this->user->nickname);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:HomeTimeline:" . $this->user->id;
$subtitle = sprintf(
......
......@@ -117,7 +117,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
_('%1$s / Updates mentioning %2$s'),
$sitename, $this->user->nickname
);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:Mentions:" . $this->user->id;
$link = common_local_url(
'replies',
......
......@@ -109,7 +109,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
$sitename = common_config('site', 'name');
$sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
$title = sprintf(_("%s public timeline"), $sitename);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:PublicTimeline";
$link = common_root_url();
$subtitle = sprintf(_("%s updates from everyone!"), $sitename);
......
......@@ -109,7 +109,7 @@ class ApiTimelineRetweetedToMeAction extends ApiAuthAction
$profile = $this->auth_user->getProfile();
$title = sprintf(_("Repeated to %s"), $this->auth_user->nickname);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:RepeatedToMe:" . $this->auth_user->id;
$link = common_local_url('all',
array('nickname' => $this->auth_user->nickname));
......
......@@ -112,7 +112,7 @@ class ApiTimelineRetweetsOfMeAction extends ApiAuthAction
$profile = $this->auth_user->getProfile();
$title = sprintf(_("Repeats of %s"), $this->auth_user->nickname);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:RepeatsOfMe:" . $this->auth_user->id;
header('Content-Type: application/atom+xml; charset=utf-8');
......
......@@ -105,7 +105,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
$this->tag,
$sitename
);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:TagTimeline:".$tag;
switch($this->format) {
......
......@@ -116,7 +116,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
$sitename = common_config('site', 'name');
$title = sprintf(_("%s timeline"), $this->user->nickname);
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$id = "tag:$taguribase:UserTimeline:" . $this->user->id;
$link = common_local_url(
'showstream',
......
......@@ -173,6 +173,10 @@ class DocAction extends Action
}
$local = glob(INSTALLDIR.'/local/doc-src/'.$this->title.'.*');
if ($local === false) {
// Some systems return false, others array(), if dir didn't exist.
$local = array();
}
if (count($local) || isset($localDef)) {
return $this->negotiateLanguage($local, $localDef);
......@@ -183,6 +187,9 @@ class DocAction extends Action
}
$dist = glob(INSTALLDIR.'/doc-src/'.$this->title.'.*');
if ($dist === false) {
$dist = array();
}
if (count($dist) || isset($distDef)) {
return $this->negotiateLanguage($dist, $distDef);
......
......@@ -79,7 +79,7 @@ class FavorAction extends Action
$this->clientError(_('This notice is already a favorite!'));
return;
}
$fave = Fave::addNew($user, $notice);
$fave = Fave::addNew($user->getProfile(), $notice);
if (!$fave) {
$this->serverError(_('Could not create favorite.'));
return;
......
......@@ -245,7 +245,7 @@ class TwitapisearchatomAction extends ApiAction
'xmlns:twitter' => 'http://api.twitter.com/',
'xml:lang' => 'en-US')); // XXX Other locales ?
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$this->element('id', null, "tag:$taguribase:search/$server");
$site_uri = common_path(false);
......@@ -329,7 +329,7 @@ class TwitapisearchatomAction extends ApiAction
$this->elementStart('entry');
$taguribase = common_config('integration', 'taguri');
$taguribase = TagURI::base();
$this->element('id', null, "tag:$taguribase:$notice->id");
$this->element('published', null, common_date_w3dtf($notice->created));
......
......@@ -21,17 +21,47 @@ class Fave extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
static function addNew($user, $notice) {
$fave = new Fave();
$fave->user_id = $user->id;
$fave->notice_id = $notice->id;
if (!$fave->insert()) {
common_log_db_error($fave, 'INSERT', __FILE__);
return false;
static function addNew($profile, $notice) {
$fave = null;
if (Event::handle('StartFavorNotice', array($profile, $notice, &$fave))) {
$fave = new Fave();
$fave->user_id = $profile->id;
$fave->notice_id = $notice->id;
if (!$fave->insert()) {
common_log_db_error($fave, 'INSERT', __FILE__);
return false;
}
Event::handle('EndFavorNotice', array($profile, $notice));
}
return $fave;
}
function delete()
{
$profile = Profile::staticGet('id', $this->user_id);
$notice = Notice::staticGet('id', $this->notice_id);
$result = null;
if (Event::handle('StartDisfavorNotice', array($profile, $notice, &$result))) {
$result = parent::delete();
if ($result) {
Event::handle('EndDisfavorNotice', array($profile, $notice));
}
}
return $result;
}
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Fave', $kv);
......
......@@ -194,6 +194,7 @@ class Notice extends Memcached_DataObject
*/
static function saveNew($profile_id, $content, $source, $options=null) {
$defaults = array('uri' => null,
'url' => null,
'reply_to' => null,
'repeat_of' => null);
......@@ -256,9 +257,16 @@ class Notice extends Memcached_DataObject
}
$notice->content = $final;
$notice->rendered = common_render_content($final, $notice);
if (!empty($rendered)) {
$notice->rendered = $rendered;
} else {
$notice->rendered = common_render_content($final, $notice);
}
$notice->source = $source;
$notice->uri = $uri;
$notice->url = $url;
// Handle repeat case
......@@ -681,7 +689,20 @@ class Notice extends Memcached_DataObject
{
$ni = $this->whoGets($groups, $recipients);
Inbox::bulkInsert($this->id, array_keys($ni));
$ids = array_keys($ni);
// We remove the author (if they're a local user),
// since we'll have already done this in distribute()
$i = array_search($this->profile_id, $ids);
if ($i !== false) {
unset($ids[$i]);
}
// Bulk insert
Inbox::bulkInsert($this->id, $ids);
return;
}
......@@ -999,6 +1020,7 @@ class Notice extends Memcached_DataObject
$xs->raw($profile->asActivityActor());
$xs->element('link', array('rel' => 'alternate',
'type' => 'text/html',
'href' => $this->bestUrl()));
$xs->element('id', null, $this->uri);
......@@ -1090,6 +1112,38 @@ class Notice extends Memcached_DataObject
return $xs->getString();
}
/**
* Returns an XML string fragment with a reference to a notice as an
* Activity Streams noun object with the given element type.
*
* Assumes that 'activity' namespace has been previously defined.
*
* @param string $element one of 'subject', 'object', 'target'
* @return string
*/
function asActivityNoun($element)
{
$xs = new XMLStringer(true);
$xs->elementStart('activity:' . $element);
$xs->element('activity:object-type',
null,
'http://activitystrea.ms/schema/1.0/note');
$xs->element('id',
null,
$this->uri);
$xs->element('content',
array('type' => 'text/html'),
$this->rendered);
$xs->element('link',
array('type' => 'text/html',
'rel' => 'alternate',
'href' => $this->bestUrl()));
$xs->elementEnd('activity:' . $element);
return $xs->getString();
}
function bestUrl()
{
if (!empty($this->url)) {
......@@ -1487,6 +1541,14 @@ class Notice extends Memcached_DataObject
function distribute()
{
// We always insert for the author so they don't
// have to wait
$user = User::staticGet('id', $this->profile_id);
if (!empty($user)) {
Inbox::insertNotice($user->id, $this->id);
}
if (common_config('queue', 'inboxes')) {
// If there's a failure, we want to _force_
// distribution at this point.
......
......@@ -868,4 +868,16 @@ class Profile extends Memcached_DataObject
return $uri;
}
function hasBlocked($other)
{
$block = Profile_block::get($this->id, $other->id);
if (empty($block)) {
$result = false;
} else {
$result = true;
}
return $result;
}
}
......@@ -24,7 +24,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Subscription extends Memcached_DataObject
class Subscription extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
......@@ -34,8 +34,8 @@ class Subscription extends Memcached_DataObject
public $subscribed; // int(4) primary_key not_null
public $jabber; // tinyint(1) default_1
public $sms; // tinyint(1) default_1
public $token; // varchar(255)
public $secret; // varchar(255)
public $token; // varchar(255)
public $secret; // varchar(255)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
......@@ -45,9 +45,155 @@ class Subscription extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */