forked from GNUsocial/gnu-social
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
Conflicts: plugins/OStatus/extlib/hkit/hkit.class.php plugins/OStatus/lib/discoveryhints.php
This commit is contained in:
commit
ac609e8040
@ -244,11 +244,17 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||||||
$options = array_merge($options, $locOptions);
|
$options = array_merge($options, $locOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->notice =
|
try {
|
||||||
Notice::saveNew($this->auth_user->id,
|
$this->notice = Notice::saveNew(
|
||||||
|
$this->auth_user->id,
|
||||||
$content,
|
$content,
|
||||||
$this->source,
|
$this->source,
|
||||||
$options);
|
$options
|
||||||
|
);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->clientError($e->getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($upload)) {
|
if (isset($upload)) {
|
||||||
$upload->attachToNotice($this->notice);
|
$upload->attachToNotice($this->notice);
|
||||||
|
@ -301,6 +301,10 @@ class AvatarsettingsAction extends AccountSettingsAction
|
|||||||
$this->showForm($e->getMessage());
|
$this->showForm($e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ($imagefile === null) {
|
||||||
|
$this->showForm(_('No file uploaded.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class SitenoticeadminpanelAction extends AdminPanelAction
|
|||||||
// assert(all values are valid);
|
// assert(all values are valid);
|
||||||
// This throws an exception on validation errors
|
// This throws an exception on validation errors
|
||||||
|
|
||||||
$this->validate(&$siteNotice);
|
$this->validate($siteNotice);
|
||||||
|
|
||||||
$config = new Config();
|
$config = new Config();
|
||||||
|
|
||||||
|
@ -62,6 +62,14 @@ class Subscription extends Memcached_DataObject
|
|||||||
|
|
||||||
static function start($subscriber, $other)
|
static function start($subscriber, $other)
|
||||||
{
|
{
|
||||||
|
// @fixme should we enforce this as profiles in callers instead?
|
||||||
|
if ($subscriber instanceof User) {
|
||||||
|
$subscriber = $subscriber->getProfile();
|
||||||
|
}
|
||||||
|
if ($other instanceof User) {
|
||||||
|
$other = $other->getProfile();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
|
if (!$subscriber->hasRight(Right::SUBSCRIBE)) {
|
||||||
throw new Exception(_('You have been banned from subscribing.'));
|
throw new Exception(_('You have been banned from subscribing.'));
|
||||||
}
|
}
|
||||||
@ -75,20 +83,7 @@ class Subscription extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Event::handle('StartSubscribe', array($subscriber, $other))) {
|
if (Event::handle('StartSubscribe', array($subscriber, $other))) {
|
||||||
|
$sub = self::saveNew($subscriber->id, $other->id);
|
||||||
$sub = new Subscription();
|
|
||||||
|
|
||||||
$sub->subscriber = $subscriber->id;
|
|
||||||
$sub->subscribed = $other->id;
|
|
||||||
$sub->created = common_sql_now();
|
|
||||||
|
|
||||||
$result = $sub->insert();
|
|
||||||
|
|
||||||
if (!$result) {
|
|
||||||
common_log_db_error($sub, 'INSERT', __FILE__);
|
|
||||||
throw new Exception(_('Could not save subscription.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$sub->notify();
|
$sub->notify();
|
||||||
|
|
||||||
self::blow('user:notices_with_friends:%d', $subscriber->id);
|
self::blow('user:notices_with_friends:%d', $subscriber->id);
|
||||||
@ -103,20 +98,11 @@ class Subscription extends Memcached_DataObject
|
|||||||
!self::exists($other, $subscriber) &&
|
!self::exists($other, $subscriber) &&
|
||||||
!$subscriber->hasBlocked($other)) {
|
!$subscriber->hasBlocked($other)) {
|
||||||
|
|
||||||
$auto = new Subscription();
|
try {
|
||||||
|
self::start($other, $subscriber);
|
||||||
$auto->subscriber = $other->id;
|
} catch (Exception $e) {
|
||||||
$auto->subscribed = $subscriber->id;
|
common_log(LOG_ERR, "Exception during autosubscribe of {$other->nickname} to profile {$subscriber->id}: {$e->getMessage()}");
|
||||||
$auto->created = common_sql_now();
|
|
||||||
|
|
||||||
$result = $auto->insert();
|
|
||||||
|
|
||||||
if (!$result) {
|
|
||||||
common_log_db_error($auto, 'INSERT', __FILE__);
|
|
||||||
throw new Exception(_('Could not save subscription.'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$auto->notify();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::handle('EndSubscribe', array($subscriber, $other));
|
Event::handle('EndSubscribe', array($subscriber, $other));
|
||||||
@ -125,6 +111,30 @@ class Subscription extends Memcached_DataObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Low-level subscription save.
|
||||||
|
* Outside callers should use Subscription::start()
|
||||||
|
*/
|
||||||
|
protected function saveNew($subscriber_id, $other_id)
|
||||||
|
{
|
||||||
|
$sub = new Subscription();
|
||||||
|
|
||||||
|
$sub->subscriber = $subscriber_id;
|
||||||
|
$sub->subscribed = $other_id;
|
||||||
|
$sub->jabber = 1;
|
||||||
|
$sub->sms = 1;
|
||||||
|
$sub->created = common_sql_now();
|
||||||
|
|
||||||
|
$result = $sub->insert();
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
common_log_db_error($sub, 'INSERT', __FILE__);
|
||||||
|
throw new Exception(_('Could not save subscription.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sub;
|
||||||
|
}
|
||||||
|
|
||||||
function notify()
|
function notify()
|
||||||
{
|
{
|
||||||
# XXX: add other notifications (Jabber, SMS) here
|
# XXX: add other notifications (Jabber, SMS) here
|
||||||
|
@ -153,19 +153,12 @@ class User extends Memcached_DataObject
|
|||||||
return Sms_carrier::staticGet('id', $this->carrier);
|
return Sms_carrier::staticGet('id', $this->carrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use Subscription::start($sub, $other);
|
||||||
|
*/
|
||||||
function subscribeTo($other)
|
function subscribeTo($other)
|
||||||
{
|
{
|
||||||
$sub = new Subscription();
|
return Subscription::start($this->getProfile(), $other);
|
||||||
$sub->subscriber = $this->id;
|
|
||||||
$sub->subscribed = $other->id;
|
|
||||||
|
|
||||||
$sub->created = common_sql_now(); // current time
|
|
||||||
|
|
||||||
if (!$sub->insert()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasBlocked($other)
|
function hasBlocked($other)
|
||||||
@ -346,17 +339,7 @@ class User extends Memcached_DataObject
|
|||||||
common_log(LOG_WARNING, sprintf("Default user %s does not exist.", $defnick),
|
common_log(LOG_WARNING, sprintf("Default user %s does not exist.", $defnick),
|
||||||
__FILE__);
|
__FILE__);
|
||||||
} else {
|
} else {
|
||||||
$defsub = new Subscription();
|
Subscription::start($user, $defuser);
|
||||||
$defsub->subscriber = $user->id;
|
|
||||||
$defsub->subscribed = $defuser->id;
|
|
||||||
$defsub->created = $user->created;
|
|
||||||
|
|
||||||
$result = $defsub->insert();
|
|
||||||
|
|
||||||
if (!$result) {
|
|
||||||
common_log_db_error($defsub, 'INSERT', __FILE__);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,7 +720,7 @@ class ActivityObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function fromNotice($notice)
|
static function fromNotice(Notice $notice)
|
||||||
{
|
{
|
||||||
$object = new ActivityObject();
|
$object = new ActivityObject();
|
||||||
|
|
||||||
@ -734,7 +734,7 @@ class ActivityObject
|
|||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function fromProfile($profile)
|
static function fromProfile(Profile $profile)
|
||||||
{
|
{
|
||||||
$object = new ActivityObject();
|
$object = new ActivityObject();
|
||||||
|
|
||||||
|
@ -67,10 +67,8 @@ class ImageFile
|
|||||||
$info[2] == IMAGETYPE_BMP ||
|
$info[2] == IMAGETYPE_BMP ||
|
||||||
($info[2] == IMAGETYPE_WBMP && function_exists('imagecreatefromwbmp')) ||
|
($info[2] == IMAGETYPE_WBMP && function_exists('imagecreatefromwbmp')) ||
|
||||||
($info[2] == IMAGETYPE_XBM && function_exists('imagecreatefromxbm')) ||
|
($info[2] == IMAGETYPE_XBM && function_exists('imagecreatefromxbm')) ||
|
||||||
($info[2] == IMAGETYPE_XPM && function_exists('imagecreatefromxpm')) ||
|
|
||||||
($info[2] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')))) {
|
($info[2] == IMAGETYPE_PNG && function_exists('imagecreatefrompng')))) {
|
||||||
|
|
||||||
@unlink($_FILES[$param]['tmp_name']);
|
|
||||||
throw new Exception(_('Unsupported image file format.'));
|
throw new Exception(_('Unsupported image file format.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -161,9 +159,6 @@ class ImageFile
|
|||||||
case IMAGETYPE_XBM:
|
case IMAGETYPE_XBM:
|
||||||
$image_src = imagecreatefromxbm($this->filepath);
|
$image_src = imagecreatefromxbm($this->filepath);
|
||||||
break;
|
break;
|
||||||
case IMAGETYPE_XPM:
|
|
||||||
$image_src = imagecreatefromxpm($this->filepath);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new Exception(_('Unknown file type'));
|
throw new Exception(_('Unknown file type'));
|
||||||
return;
|
return;
|
||||||
@ -206,10 +201,6 @@ class ImageFile
|
|||||||
//we don't want to save XBM... it's a rare format that we can't guarantee clients will support
|
//we don't want to save XBM... it's a rare format that we can't guarantee clients will support
|
||||||
//save png instead
|
//save png instead
|
||||||
$this->type = IMAGETYPE_PNG;
|
$this->type = IMAGETYPE_PNG;
|
||||||
} else if($this->type == IMAGETYPE_XPM) {
|
|
||||||
//we don't want to save XPM... it's a rare format that we can't guarantee clients will support
|
|
||||||
//save png instead
|
|
||||||
$this->type = IMAGETYPE_PNG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$outname = Avatar::filename($this->id,
|
$outname = Avatar::filename($this->id,
|
||||||
|
@ -299,7 +299,7 @@ class OStatusSubAction extends Action
|
|||||||
if ($user->isSubscribed($local)) {
|
if ($user->isSubscribed($local)) {
|
||||||
// TRANS: OStatus remote subscription dialog error.
|
// TRANS: OStatus remote subscription dialog error.
|
||||||
$this->showForm(_m('Already subscribed!'));
|
$this->showForm(_m('Already subscribed!'));
|
||||||
} elseif ($this->oprofile->subscribeLocalToRemote($user)) {
|
} elseif (Subscription::start($user, $local)) {
|
||||||
$this->success();
|
$this->success();
|
||||||
} else {
|
} else {
|
||||||
// TRANS: OStatus remote subscription dialog error.
|
// TRANS: OStatus remote subscription dialog error.
|
||||||
|
@ -194,52 +194,6 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Subscribe a local user to this remote user.
|
|
||||||
* PuSH subscription will be started if necessary, and we'll
|
|
||||||
* send a Salmon notification to the remote server if available
|
|
||||||
* notifying them of the sub.
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
* @return boolean success
|
|
||||||
* @throws FeedException
|
|
||||||
*/
|
|
||||||
public function subscribeLocalToRemote(User $user)
|
|
||||||
{
|
|
||||||
if ($this->isGroup()) {
|
|
||||||
throw new ServerException("Can't subscribe to a remote group");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->subscribe()) {
|
|
||||||
if ($user->subscribeTo($this->localProfile())) {
|
|
||||||
$this->notify($user->getProfile(), ActivityVerb::FOLLOW, $this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mark this remote profile as subscribing to the given local user,
|
|
||||||
* and send appropriate notifications to the user.
|
|
||||||
*
|
|
||||||
* This will generally be in response to a subscription notification
|
|
||||||
* from a foreign site to our local Salmon response channel.
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
* @return boolean success
|
|
||||||
*/
|
|
||||||
public function subscribeRemoteToLocal(User $user)
|
|
||||||
{
|
|
||||||
if ($this->isGroup()) {
|
|
||||||
throw new ServerException("Remote groups can't subscribe to local users");
|
|
||||||
}
|
|
||||||
|
|
||||||
Subscription::start($this->localProfile(), $user->getProfile());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a subscription request to the hub for this feed.
|
* Send a subscription request to the hub for this feed.
|
||||||
* The hub will later send us a confirmation POST to /main/push/callback.
|
* The hub will later send us a confirmation POST to /main/push/callback.
|
||||||
@ -1449,7 +1403,7 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
|
|
||||||
if (array_key_exists('feedurl', $hints)) {
|
if (array_key_exists('feedurl', $hints)) {
|
||||||
try {
|
try {
|
||||||
common_log(LOG_INFO, "Discovery on acct:$addr with feed URL $feedUrl");
|
common_log(LOG_INFO, "Discovery on acct:$addr with feed URL " . $hints['feedurl']);
|
||||||
$oprofile = self::ensureFeedURL($hints['feedurl'], $hints);
|
$oprofile = self::ensureFeedURL($hints['feedurl'], $hints);
|
||||||
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
|
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
|
||||||
return $oprofile;
|
return $oprofile;
|
||||||
|
@ -43,7 +43,7 @@ class LinkHeader
|
|||||||
static function getLink($response, $rel=null, $type=null)
|
static function getLink($response, $rel=null, $type=null)
|
||||||
{
|
{
|
||||||
$headers = $response->getHeader('Link');
|
$headers = $response->getHeader('Link');
|
||||||
|
if ($headers) {
|
||||||
// Can get an array or string, so try to simplify the path
|
// Can get an array or string, so try to simplify the path
|
||||||
if (!is_array($headers)) {
|
if (!is_array($headers)) {
|
||||||
$headers = array($headers);
|
$headers = array($headers);
|
||||||
@ -57,7 +57,7 @@ class LinkHeader
|
|||||||
return $lh->href;
|
return $lh->href;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user