Removing MicroID as well as simplifying profileaction

sorry, forgot to commit in between
This commit is contained in:
Mikael Nordfeldth 2015-07-14 16:52:20 +02:00
parent e868ac41cd
commit 01a4ab30dc
12 changed files with 33 additions and 236 deletions

View File

@ -231,12 +231,6 @@ class EmailsettingsAction extends SettingsAction
_('Allow friends to nudge me and send me an email.'), _('Allow friends to nudge me and send me an email.'),
$user->emailnotifynudge); $user->emailnotifynudge);
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementStart('li');
$this->checkbox('emailmicroid',
// TRANS: Checkbox label in e-mail preferences form.
_('Publish a MicroID for my email address.'),
$user->emailmicroid);
$this->elementEnd('li');
Event::handle('EndEmailFormData', array($this, $this->scoped)); Event::handle('EndEmailFormData', array($this, $this->scoped));
} }
$this->elementEnd('ul'); $this->elementEnd('ul');
@ -320,7 +314,6 @@ class EmailsettingsAction extends SettingsAction
$emailnotifymsg = $this->booleanintstring('emailnotifymsg'); $emailnotifymsg = $this->booleanintstring('emailnotifymsg');
$emailnotifynudge = $this->booleanintstring('emailnotifynudge'); $emailnotifynudge = $this->booleanintstring('emailnotifynudge');
$emailnotifyattn = $this->booleanintstring('emailnotifyattn'); $emailnotifyattn = $this->booleanintstring('emailnotifyattn');
$emailmicroid = $this->booleanintstring('emailmicroid');
$emailpost = $this->booleanintstring('emailpost'); $emailpost = $this->booleanintstring('emailpost');
$user->query('BEGIN'); $user->query('BEGIN');
@ -331,7 +324,6 @@ class EmailsettingsAction extends SettingsAction
$user->emailnotifymsg = $emailnotifymsg; $user->emailnotifymsg = $emailnotifymsg;
$user->emailnotifynudge = $emailnotifynudge; $user->emailnotifynudge = $emailnotifynudge;
$user->emailnotifyattn = $emailnotifyattn; $user->emailnotifyattn = $emailnotifyattn;
$user->emailmicroid = $emailmicroid;
$user->emailpost = $emailpost; $user->emailpost = $emailpost;
$result = $user->update($original); $result = $user->update($original);

View File

@ -28,12 +28,7 @@
* @link http://status.net/ * @link http://status.net/
*/ */
if (!defined('STATUSNET') && !defined('LACONICA')) { if (!defined('GNUSOCIAL')) { exit(1); }
exit(1);
}
require_once INSTALLDIR.'/lib/noticelist.php';
require_once INSTALLDIR.'/lib/feedlist.php';
/** /**
* Permalink for a group * Permalink for a group

View File

@ -179,8 +179,6 @@ class ImsettingsAction extends SettingsAction
// TRANS: Checkbox label in IM preferences form. // TRANS: Checkbox label in IM preferences form.
array('name'=>'replies', 'description'=>_('Send me replies '. array('name'=>'replies', 'description'=>_('Send me replies '.
'from people I\'m not subscribed to.')), 'from people I\'m not subscribed to.')),
// TRANS: Checkbox label in IM preferences form.
array('name'=>'microid', 'description'=>_('Publish a MicroID'))
); );
foreach($preferences as $preference) foreach($preferences as $preference)
{ {
@ -277,7 +275,7 @@ class ImsettingsAction extends SettingsAction
$user_im_prefs->user_id = $user->id; $user_im_prefs->user_id = $user->id;
if($user_im_prefs->find() && $user_im_prefs->fetch()) if($user_im_prefs->find() && $user_im_prefs->fetch())
{ {
$preferences = array('notify', 'updatefrompresence', 'replies', 'microid'); $preferences = array('notify', 'updatefrompresence', 'replies');
do do
{ {
$original = clone($user_im_prefs); $original = clone($user_im_prefs);

View File

@ -222,25 +222,12 @@ class ShownoticeAction extends ManagedAction
/** /**
* Extra <head> content * Extra <head> content
* *
* We show the microid(s) for the author, if any. * Facebook OpenGraph metadata.
* *
* @return void * @return void
*/ */
function extraHead() function extraHead()
{ {
$user = User::getKV($this->profile->id);
if (!$user instanceof User) {
return;
}
if ($user->emailmicroid && $user->email && $this->notice->uri) {
$id = new Microid('mailto:'. $user->email,
$this->notice->uri);
$this->element('meta', array('name' => 'microid',
'content' => $id->toString()));
}
// Extras to aid in sharing notices to Facebook // Extras to aid in sharing notices to Facebook
$avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE); $avatarUrl = $this->profile->avatarUrl(AVATAR_PROFILE_SIZE);
$this->element('meta', array('property' => 'og:image', $this->element('meta', array('property' => 'og:image',

View File

@ -47,38 +47,6 @@ if (!defined('GNUSOCIAL')) { exit(1); }
*/ */
class ShowstreamAction extends NoticestreamAction class ShowstreamAction extends NoticestreamAction
{ {
protected $target = null;
protected function doPreparation()
{
// showstream requires a nickname
$nickname_arg = $this->trimmed('nickname');
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname);
if ($this->arg('page') && $this->arg('page') != 1) {
$args['page'] = $this->arg['page'];
}
common_redirect(common_local_url($this->getActionName(), $args), 301);
}
try {
$user = User::getByNickname($nickname);
} catch (NoSuchUserException $e) {
$group = Local_group::getKV('nickname', $nickname);
if ($group instanceof Local_group) {
common_redirect($group->getProfile()->getUrl());
}
// No user nor group found, throw the NoSuchUserException again
throw $e;
}
$this->target = $user->getProfile();
}
public function getStream() public function getStream()
{ {
if (empty($this->tag)) { if (empty($this->tag)) {
@ -195,13 +163,6 @@ class ShowstreamAction extends NoticestreamAction
'content' => $this->target->getDescription())); 'content' => $this->target->getDescription()));
} }
if ($this->target->isLocal() && $this->target->getUser()->emailmicroid && $this->target->getUser()->email && $this->target->getUrl()) {
$id = new Microid('mailto:'.$this->target->getUser()->email,
$this->selfUrl());
$this->element('meta', array('name' => 'microid',
'content' => $id->toString()));
}
// See https://wiki.mozilla.org/Microsummaries // See https://wiki.mozilla.org/Microsummaries
$this->element('link', array('rel' => 'microsummary', $this->element('link', array('rel' => 'microsummary',

View File

@ -42,7 +42,6 @@ class User extends Managed_DataObject
public $emailnotifynudge; // tinyint(1) default_1 public $emailnotifynudge; // tinyint(1) default_1
public $emailnotifymsg; // tinyint(1) default_1 public $emailnotifymsg; // tinyint(1) default_1
public $emailnotifyattn; // tinyint(1) default_1 public $emailnotifyattn; // tinyint(1) default_1
public $emailmicroid; // tinyint(1) default_1
public $language; // varchar(50) public $language; // varchar(50)
public $timezone; // varchar(50) public $timezone; // varchar(50)
public $emailpost; // tinyint(1) default_1 public $emailpost; // tinyint(1) default_1
@ -77,7 +76,6 @@ class User extends Managed_DataObject
'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'), 'emailnotifynudge' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of nudges'),
'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'), 'emailnotifymsg' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of direct messages'),
'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'), 'emailnotifyattn' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Notify by email of @-replies'),
'emailmicroid' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'whether to publish email microid'),
'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'), 'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'),
'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'), 'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'),
'emailpost' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Post by email'), 'emailpost' => array('type' => 'int', 'size' => 'tiny', 'default' => 1, 'description' => 'Post by email'),
@ -276,9 +274,7 @@ class User extends Managed_DataObject
$user->emailnotifynudge = 1; $user->emailnotifynudge = 1;
$user->emailnotifymsg = 1; $user->emailnotifymsg = 1;
$user->emailnotifyattn = 1; $user->emailnotifyattn = 1;
$user->emailmicroid = 1;
$user->emailpost = 1; $user->emailpost = 1;
$user->jabbermicroid = 1;
$user->created = common_sql_now(); $user->created = common_sql_now();

View File

@ -40,7 +40,6 @@ class User_im_prefs extends Managed_DataObject
public $transport; // varchar(191) not_null not 255 because utf8mb4 takes more space public $transport; // varchar(191) not_null not 255 because utf8mb4 takes more space
public $notify; // tinyint(1) public $notify; // tinyint(1)
public $replies; // tinyint(1) public $replies; // tinyint(1)
public $microid; // tinyint(1)
public $updatefrompresence; // tinyint(1) public $updatefrompresence; // tinyint(1)
public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00 public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00
public $modified; // timestamp not_null default_CURRENT_TIMESTAMP public $modified; // timestamp not_null default_CURRENT_TIMESTAMP
@ -57,7 +56,6 @@ class User_im_prefs extends Managed_DataObject
'transport' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex xmpp, aim)'), 'transport' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'transport (ex xmpp, aim)'),
'notify' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Notify when a new notice is sent'), 'notify' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Notify when a new notice is sent'),
'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to'), 'replies' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to'),
'microid' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => 'Publish a MicroID'),
'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to.'), 'updatefrompresence' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 0, 'description' => 'Send replies from people not subscribed to.'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),

View File

@ -36,35 +36,6 @@ class GalleryAction extends ProfileAction
parent::handle(); parent::handle();
} }
protected function doPreparation()
{
// showstream requires a nickname
$nickname_arg = $this->arg('nickname');
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname);
if ($this->arg('page') && $this->arg('page') != 1) {
$args['page'] = $this->arg['page'];
}
common_redirect(common_local_url($this->getActionName(), $args), 301);
}
$this->user = User::getKV('nickname', $nickname);
if (!$this->user) {
$group = Local_group::getKV('nickname', $nickname);
if ($group instanceof Local_group) {
common_redirect($group->getProfile()->getUrl());
}
// TRANS: Client error displayed when calling a profile action without specifying a user.
$this->clientError(_('No such user.'), 404);
}
$this->target = $this->user->getProfile();
}
function showContent() function showContent()
{ {
$this->showTagsDropdown(); $this->showTagsDropdown();

View File

@ -126,17 +126,6 @@ abstract class ImPlugin extends Plugin
*/ */
abstract function daemonScreenname(); abstract function daemonScreenname();
/**
* get the microid uri of a given screenname
*
* @param string $screenname screenname
*
* @return string microid uri
*/
function microiduri($screenname)
{
return $this->transport . ':' . $screenname;
}
//========================UTILITY FUNCTIONS USEFUL TO IMPLEMENTATIONS - MISC ========================\ //========================UTILITY FUNCTIONS USEFUL TO IMPLEMENTATIONS - MISC ========================\
/** /**
@ -571,25 +560,12 @@ abstract class ImPlugin extends Plugin
$user_im_prefs->user_id = $action->notice->getProfile()->getID(); $user_im_prefs->user_id = $action->notice->getProfile()->getID();
$user_im_prefs->transport = $this->transport; $user_im_prefs->transport = $this->transport;
if ($user_im_prefs->find() && $user_im_prefs->fetch() && $user_im_prefs->microid && $action->notice->uri) {
$id = new Microid($this->microiduri($user_im_prefs->screenname),
$action->notice->uri);
$action->element('meta', array('name' => 'microid',
'content' => $id->toString()));
}
} elseif ($action instanceof ShowstreamAction) { } elseif ($action instanceof ShowstreamAction) {
$user_im_prefs = new User_im_prefs(); $user_im_prefs = new User_im_prefs();
$user_im_prefs->user_id = $action->getTarget()->getID(); $user_im_prefs->user_id = $action->getTarget()->getID();
$user_im_prefs->transport = $this->transport; $user_im_prefs->transport = $this->transport;
if ($user_im_prefs->find() && $user_im_prefs->fetch() && $user_im_prefs->microid && $action->getTarget()->getUrl()) {
$id = new Microid($this->microiduri($user_im_prefs->screenname),
$action->selfUrl());
$action->element('meta', array('name' => 'microid',
'content' => $id->toString()));
}
} }
} }

View File

@ -1,97 +0,0 @@
<?php
/**
* StatusNet, the distributed open-source microblogging tool
*
* Microid class
*
* PHP version 5
*
* LICENCE: 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/>.
*
* @category ID
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @copyright 2008 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
/**
* A class for microids
*
* @category ID
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @see http://microid.org/
*/
class Microid
{
/** Agent part of the ID. */
var $agent = null;
/** Resource part of the ID. */
var $resource = null;
/**
* Constructor
*
* @param string $agent Agent of the ID
* @param string $resource Resource part
*/
function __construct($agent, $resource)
{
$this->agent = $agent;
$this->resource = $resource;
}
/**
* Generate a MicroID string
*
* @return string MicroID for agent and resource
*/
function toString()
{
$agent_proto = $this->_getProto($this->agent);
$resource_proto = $this->_getProto($this->resource);
return $agent_proto.'+'.$resource_proto.':sha1:'.
sha1(sha1($this->agent).sha1($this->resource));
}
/**
* Utility for getting the protocol part of a URI
*
* @param string $uri URI to parse
*
* @return string scheme part of the URI
*/
function _getProto($uri)
{
$colon = strpos($uri, ':');
return substr($uri, 0, $colon);
}
}

View File

@ -48,6 +48,36 @@ abstract class ProfileAction extends ManagedAction
protected $target = null; // Profile that we're showing protected $target = null; // Profile that we're showing
protected function doPreparation()
{
// showstream requires a nickname
$nickname_arg = $this->trimmed('nickname');
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname);
if ($this->arg('page') && $this->arg('page') != 1) {
$args['page'] = $this->arg['page'];
}
common_redirect(common_local_url($this->getActionName(), $args), 301);
}
try {
$user = User::getByNickname($nickname);
} catch (NoSuchUserException $e) {
$group = Local_group::getKV('nickname', $nickname);
if ($group instanceof Local_group) {
common_redirect($group->getProfile()->getUrl());
}
// No user nor group found, throw the NoSuchUserException again
throw $e;
}
$this->target = $user->getProfile();
}
protected function prepare(array $args=array()) protected function prepare(array $args=array())
{ {
// this will call ->doPreparation() which child classes use to set $this->target // this will call ->doPreparation() which child classes use to set $this->target
@ -65,11 +95,6 @@ abstract class ProfileAction extends ManagedAction
return true; return true;
} }
protected function profileActionPreparation()
{
// Nothing to do by default.
}
public function getTarget() public function getTarget()
{ {
if (!$this->target instanceof Profile) { if (!$this->target instanceof Profile) {

View File

@ -308,11 +308,6 @@ class XmppPlugin extends ImPlugin
return true; return true;
} }
function microiduri($screenname)
{
return 'xmpp:' . $screenname;
}
function sendMessage($screenname, $body) function sendMessage($screenname, $body)
{ {
$this->queuedConnection()->message($screenname, $body, 'chat'); $this->queuedConnection()->message($screenname, $body, 'chat');