Merge branch 'master' into testing
This commit is contained in:
commit
dd7b95c2cf
@ -1006,8 +1006,6 @@ class Notice extends Memcached_DataObject
|
|||||||
$reply->profile_id = $user->id;
|
$reply->profile_id = $user->id;
|
||||||
|
|
||||||
$id = $reply->insert();
|
$id = $reply->insert();
|
||||||
|
|
||||||
self::blow('reply:stream:%d', $user->id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,6 +1071,7 @@ class Notice extends Memcached_DataObject
|
|||||||
throw new ServerException("Couldn't save reply for {$this->id}, {$mentioned->id}");
|
throw new ServerException("Couldn't save reply for {$this->id}, {$mentioned->id}");
|
||||||
} else {
|
} else {
|
||||||
$replied[$mentioned->id] = 1;
|
$replied[$mentioned->id] = 1;
|
||||||
|
self::blow('reply:stream:%d', $mentioned->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1128,7 +1127,6 @@ class Notice extends Memcached_DataObject
|
|||||||
foreach ($recipientIds as $recipientId) {
|
foreach ($recipientIds as $recipientId) {
|
||||||
$user = User::staticGet('id', $recipientId);
|
$user = User::staticGet('id', $recipientId);
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
self::blow('reply:stream:%d', $recipientId);
|
|
||||||
mail_notify_attn($user, $this);
|
mail_notify_attn($user, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,20 @@ class Reply extends Memcached_DataObject
|
|||||||
/* the code above is auto generated do not remove the tag below */
|
/* the code above is auto generated do not remove the tag below */
|
||||||
###END_AUTOCODE
|
###END_AUTOCODE
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for record insertion to update related caches
|
||||||
|
*/
|
||||||
|
function insert()
|
||||||
|
{
|
||||||
|
$result = parent::insert();
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
self::blow('reply:stream:%d', $this->profile_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
|
||||||
{
|
{
|
||||||
$ids = Notice::stream(array('Reply', '_streamDirect'),
|
$ids = Notice::stream(array('Reply', '_streamDirect'),
|
||||||
|
@ -262,7 +262,7 @@ class BlacklistPlugin extends Plugin
|
|||||||
$patterns = $this->_getUrlPatterns();
|
$patterns = $this->_getUrlPatterns();
|
||||||
|
|
||||||
foreach ($patterns as $pattern) {
|
foreach ($patterns as $pattern) {
|
||||||
if (preg_match("/$pattern/", $url)) {
|
if ($pattern != '' && preg_match("/$pattern/", $url)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ class BlacklistPlugin extends Plugin
|
|||||||
$patterns = $this->_getNicknamePatterns();
|
$patterns = $this->_getNicknamePatterns();
|
||||||
|
|
||||||
foreach ($patterns as $pattern) {
|
foreach ($patterns as $pattern) {
|
||||||
if (preg_match("/$pattern/", $nickname)) {
|
if ($pattern != '' && preg_match("/$pattern/", $nickname)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class Homepage_blacklist extends Memcached_DataObject
|
|||||||
|
|
||||||
function keys()
|
function keys()
|
||||||
{
|
{
|
||||||
return array('pattern' => 'K');
|
return array_keys($this->keyTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +108,7 @@ class Homepage_blacklist extends Memcached_DataObject
|
|||||||
|
|
||||||
function keyTypes()
|
function keyTypes()
|
||||||
{
|
{
|
||||||
return $this->keys();
|
return array('pattern' => 'K');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ class Nickname_blacklist extends Memcached_DataObject
|
|||||||
|
|
||||||
function keys()
|
function keys()
|
||||||
{
|
{
|
||||||
return array('pattern' => 'K');
|
return array_keys($this->keyTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,7 +99,7 @@ class Nickname_blacklist extends Memcached_DataObject
|
|||||||
|
|
||||||
function keyTypes()
|
function keyTypes()
|
||||||
{
|
{
|
||||||
return $this->keys();
|
return array('pattern' => 'K');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,28 +88,27 @@ class BlacklistadminpanelAction extends AdminPanelAction
|
|||||||
|
|
||||||
function saveSettings()
|
function saveSettings()
|
||||||
{
|
{
|
||||||
$nickPatterns = array();
|
$nickPatterns = $this->splitPatterns($this->trimmed('blacklist-nicknames'));
|
||||||
|
|
||||||
$rawNickPatterns = explode("\n", $this->trimmed('blacklist-nicknames'));
|
|
||||||
|
|
||||||
foreach ($rawNickPatterns as $raw) {
|
|
||||||
$nickPatterns[] = trim($raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
Nickname_blacklist::saveNew($nickPatterns);
|
Nickname_blacklist::saveNew($nickPatterns);
|
||||||
|
|
||||||
$rawUrlPatterns = explode("\n", $this->trimmed('blacklist-urls'));
|
$urlPatterns = $this->splitPatterns($this->trimmed('blacklist-urls'));
|
||||||
$urlPatterns = array();
|
|
||||||
|
|
||||||
foreach ($rawUrlPatterns as $raw) {
|
|
||||||
$urlPatterns[] = trim($raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
Homepage_blacklist::saveNew($urlPatterns);
|
Homepage_blacklist::saveNew($urlPatterns);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function splitPatterns($text)
|
||||||
|
{
|
||||||
|
$patterns = array();
|
||||||
|
foreach (explode("\n", $text) as $raw) {
|
||||||
|
$trimmed = trim($raw);
|
||||||
|
if ($trimmed != '') {
|
||||||
|
$patterns[] = $trimmed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $patterns;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the values
|
* Validate the values
|
||||||
*
|
*
|
||||||
|
@ -1001,7 +1001,7 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!common_valid_http_url($url)) {
|
if (!common_valid_http_url($url)) {
|
||||||
throw new ServerException(_m("Invalid avatar URL %s"), $url);
|
throw new ServerException(sprintf(_m("Invalid avatar URL %s"), $url));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isGroup()) {
|
if ($this->isGroup()) {
|
||||||
@ -1303,15 +1303,23 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
|
|
||||||
$ok = $oprofile->insert();
|
$ok = $oprofile->insert();
|
||||||
|
|
||||||
if ($ok) {
|
if (!$ok) {
|
||||||
$avatar = self::getActivityObjectAvatar($object, $hints);
|
|
||||||
if ($avatar) {
|
|
||||||
$oprofile->updateAvatar($avatar);
|
|
||||||
}
|
|
||||||
return $oprofile;
|
|
||||||
} else {
|
|
||||||
throw new ServerException("Can't save OStatus profile");
|
throw new ServerException("Can't save OStatus profile");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$avatar = self::getActivityObjectAvatar($object, $hints);
|
||||||
|
|
||||||
|
if ($avatar) {
|
||||||
|
try {
|
||||||
|
$oprofile->updateAvatar($avatar);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
// Profile is saved, but Avatar is messed up. We're
|
||||||
|
// just going to continue.
|
||||||
|
common_log(LOG_WARNING, "Exception saving OStatus profile avatar: ". $ex->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $oprofile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1330,7 +1338,11 @@ class Ostatus_profile extends Memcached_DataObject
|
|||||||
}
|
}
|
||||||
$avatar = self::getActivityObjectAvatar($object, $hints);
|
$avatar = self::getActivityObjectAvatar($object, $hints);
|
||||||
if ($avatar) {
|
if ($avatar) {
|
||||||
$this->updateAvatar($avatar);
|
try {
|
||||||
|
$this->updateAvatar($avatar);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
common_log(LOG_WARNING, "Exception saving OStatus profile avatar: " . $ex->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
74
plugins/OStatus/scripts/resub-feed.php
Normal file
74
plugins/OStatus/scripts/resub-feed.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StatusNet - a distributed open-source microblogging tool
|
||||||
|
* Copyright (C) 2010, StatusNet, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
||||||
|
|
||||||
|
$helptext = <<<END_OF_HELP
|
||||||
|
resub-feed.php [options] http://example.com/atom-feed-url
|
||||||
|
Reinitialize the PuSH subscription for the given feed. This may help get
|
||||||
|
things restarted if we and the hub have gotten our states out of sync.
|
||||||
|
|
||||||
|
|
||||||
|
END_OF_HELP;
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||||
|
|
||||||
|
if (empty($args[0]) || !Validate::uri($args[0])) {
|
||||||
|
print "$helptext";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$feedurl = $args[0];
|
||||||
|
|
||||||
|
|
||||||
|
$sub = FeedSub::staticGet('topic', $feedurl);
|
||||||
|
if (!$sub) {
|
||||||
|
print "Feed $feedurl is not subscribed.\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Old state:\n";
|
||||||
|
showSub($sub);
|
||||||
|
|
||||||
|
print "\n";
|
||||||
|
print "Pinging hub $sub->huburi with new subscription for $sub->uri\n";
|
||||||
|
$ok = $sub->subscribe();
|
||||||
|
|
||||||
|
if ($ok) {
|
||||||
|
print "ok\n";
|
||||||
|
} else {
|
||||||
|
print "Could not confirm.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sub2 = FeedSub::staticGet('topic', $feedurl);
|
||||||
|
|
||||||
|
print "\n";
|
||||||
|
print "New state:\n";
|
||||||
|
showSub($sub2);
|
||||||
|
|
||||||
|
function showSub($sub)
|
||||||
|
{
|
||||||
|
print " Subscription state: $sub->sub_state\n";
|
||||||
|
print " Verify token: $sub->verify_token\n";
|
||||||
|
print " Signature secret: $sub->secret\n";
|
||||||
|
print " Sub start date: $sub->sub_start\n";
|
||||||
|
print " Record created: $sub->created\n";
|
||||||
|
print " Record modified: $sub->modified\n";
|
||||||
|
}
|
147
plugins/OStatus/scripts/update-profile.php
Normal file
147
plugins/OStatus/scripts/update-profile.php
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* StatusNet - a distributed open-source microblogging tool
|
||||||
|
* Copyright (C) 2010, StatusNet, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
|
||||||
|
|
||||||
|
$helptext = <<<END_OF_HELP
|
||||||
|
update-profile.php [options] http://example.com/profile/url
|
||||||
|
|
||||||
|
Rerun profile and feed info discovery for the given OStatus remote profile,
|
||||||
|
and reinitialize its PuSH subscription for the given feed. This may help get
|
||||||
|
things restarted if the hub or feed URLs have changed for the profile.
|
||||||
|
|
||||||
|
|
||||||
|
END_OF_HELP;
|
||||||
|
|
||||||
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||||
|
|
||||||
|
if (empty($args[0]) || !Validate::uri($args[0])) {
|
||||||
|
print "$helptext";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uri = $args[0];
|
||||||
|
|
||||||
|
|
||||||
|
$oprofile = Ostatus_profile::staticGet('uri', $uri);
|
||||||
|
|
||||||
|
if (!$oprofile) {
|
||||||
|
print "No OStatus remote profile known for URI $uri\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Old profile state for $oprofile->uri\n";
|
||||||
|
showProfile($oprofile);
|
||||||
|
|
||||||
|
print "\n";
|
||||||
|
print "Re-running feed discovery for profile URL $oprofile->uri\n";
|
||||||
|
// @fixme will bork where the URI isn't the profile URL for now
|
||||||
|
$discover = new FeedDiscovery();
|
||||||
|
$feedurl = $discover->discoverFromURL($oprofile->uri);
|
||||||
|
$huburi = $discover->getAtomLink('hub');
|
||||||
|
$salmonuri = $discover->getAtomLink(Salmon::NS_REPLIES);
|
||||||
|
|
||||||
|
print " Feed URL: $feedurl\n";
|
||||||
|
print " Hub URL: $huburi\n";
|
||||||
|
print " Salmon URL: $salmonuri\n";
|
||||||
|
|
||||||
|
if ($feedurl != $oprofile->feeduri || $salmonuri != $oprofile->salmonuri) {
|
||||||
|
print "\n";
|
||||||
|
print "Updating...\n";
|
||||||
|
// @fixme update keys :P
|
||||||
|
#$orig = clone($oprofile);
|
||||||
|
#$oprofile->feeduri = $feedurl;
|
||||||
|
#$oprofile->salmonuri = $salmonuri;
|
||||||
|
#$ok = $oprofile->update($orig);
|
||||||
|
$ok = $oprofile->query('UPDATE ostatus_profile SET ' .
|
||||||
|
'feeduri=\'' . $oprofile->escape($feedurl) . '\',' .
|
||||||
|
'salmonuri=\'' . $oprofile->escape($salmonuri) . '\' ' .
|
||||||
|
'WHERE uri=\'' . $oprofile->escape($uri) . '\'');
|
||||||
|
|
||||||
|
if (!$ok) {
|
||||||
|
print "Failed to update profile record...\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$oprofile->decache();
|
||||||
|
} else {
|
||||||
|
print "\n";
|
||||||
|
print "Ok, ostatus_profile record unchanged.\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sub = FeedSub::ensureFeed($feedurl);
|
||||||
|
|
||||||
|
if ($huburi != $sub->huburi) {
|
||||||
|
print "\n";
|
||||||
|
print "Updating hub record for feed; was $sub->huburi\n";
|
||||||
|
$orig = clone($sub);
|
||||||
|
$sub->huburi = $huburi;
|
||||||
|
$ok = $sub->update($orig);
|
||||||
|
|
||||||
|
if (!$ok) {
|
||||||
|
print "Failed to update sub record...\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print "\n";
|
||||||
|
print "Feed record ok, not changing.\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "\n";
|
||||||
|
print "Pinging hub $sub->huburi with new subscription for $sub->uri\n";
|
||||||
|
$ok = $sub->subscribe();
|
||||||
|
|
||||||
|
if ($ok) {
|
||||||
|
print "ok\n";
|
||||||
|
} else {
|
||||||
|
print "Could not confirm.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$o2 = Ostatus_profile::staticGet('uri', $uri);
|
||||||
|
|
||||||
|
print "\n";
|
||||||
|
print "New profile state:\n";
|
||||||
|
showProfile($o2);
|
||||||
|
|
||||||
|
print "\n";
|
||||||
|
print "New feed state:\n";
|
||||||
|
$sub2 = FeedSub::ensureFeed($feedurl);
|
||||||
|
showSub($sub2);
|
||||||
|
|
||||||
|
function showProfile($oprofile)
|
||||||
|
{
|
||||||
|
print " Feed URL: $oprofile->feeduri\n";
|
||||||
|
print " Salmon URL: $oprofile->salmonuri\n";
|
||||||
|
print " Avatar URL: $oprofile->avatar\n";
|
||||||
|
print " Profile ID: $oprofile->profile_id\n";
|
||||||
|
print " Group ID: $oprofile->group_id\n";
|
||||||
|
print " Record created: $oprofile->created\n";
|
||||||
|
print " Record modified: $oprofile->modified\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSub($sub)
|
||||||
|
{
|
||||||
|
print " Subscription state: $sub->sub_state\n";
|
||||||
|
print " Verify token: $sub->verify_token\n";
|
||||||
|
print " Signature secret: $sub->secret\n";
|
||||||
|
print " Sub start date: $sub->sub_start\n";
|
||||||
|
print " Record created: $sub->created\n";
|
||||||
|
print " Record modified: $sub->modified\n";
|
||||||
|
}
|
@ -299,11 +299,21 @@ class AutosubmitAction extends Action
|
|||||||
|
|
||||||
function title()
|
function title()
|
||||||
{
|
{
|
||||||
return _m('OpenID Auto-Submit');
|
return _m('OpenID Login Submission');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showContent()
|
function showContent()
|
||||||
{
|
{
|
||||||
|
$this->raw('<p style="margin: 20px 80px">');
|
||||||
|
// @fixme this would be better using standard CSS class, but the present theme's a bit scary.
|
||||||
|
$this->element('img', array('src' => Theme::path('images/icons/icon_processing.gif', 'base'),
|
||||||
|
// for some reason the base CSS sets <img>s as block display?!
|
||||||
|
'style' => 'display: inline'));
|
||||||
|
$this->text(_m('Requesting authorization from your login provider...'));
|
||||||
|
$this->raw('</p>');
|
||||||
|
$this->raw('<p style="margin-top: 60px; font-style: italic">');
|
||||||
|
$this->text(_m('If you are not redirected to your login provider in a few seconds, try pushing the button below.'));
|
||||||
|
$this->raw('</p>');
|
||||||
$this->raw($this->form_html);
|
$this->raw($this->form_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,8 +321,6 @@ class AutosubmitAction extends Action
|
|||||||
{
|
{
|
||||||
parent::showScripts();
|
parent::showScripts();
|
||||||
$this->element('script', null,
|
$this->element('script', null,
|
||||||
'$(document).ready(function() { ' .
|
'document.getElementById(\'' . $this->form_id . '\').submit();');
|
||||||
' $(\'#'. $this->form_id .'\').submit(); '.
|
|
||||||
'});');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ class RSSCloudPlugin extends Plugin
|
|||||||
*
|
*
|
||||||
* Hook for RouterInitialized event.
|
* Hook for RouterInitialized event.
|
||||||
*
|
*
|
||||||
* @param Mapper &$m URL parser and mapper
|
* @param Mapper $m URL parser and mapper
|
||||||
*
|
*
|
||||||
* @return boolean hook return
|
* @return boolean hook return
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user