Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Removed node.discover and related from QuickSocial (use node.synchron…
Browse files Browse the repository at this point in the history
…ize instead)
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Dec 28, 2010
1 parent 08328f5 commit af47151
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 106 deletions.
13 changes: 0 additions & 13 deletions _documentation/quicksocial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ Protocol
- NOTE: If _username is empty, represents a site verification token only.

QuickNode
- Discover / ReplyToDiscover
- GET: _social=true
_task=node.discover
_source=<domain> # Domain source
_token=<token> # Required for verification
- JSON: success=<true|false>
error=<error>
methods=<[array]>
tasks=<[array=(verify,node.update,friend.add,etc)]>
trusted=<[array]>
version=<version>
- NOTE: Source & Token optional

- Synchronize / ReplyToSynchronize
- GET: _social=true
_task=node.synchronize
Expand Down
3 changes: 2 additions & 1 deletion _release/update-0.7.9.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ create table `#__SchemaVersions` ( `Schema_PK` timestamp NOT NULL DEFAULT CURREN

insert into `#__SchemaVersions` ( `Version`, `Notes` ) values ( '0.7.9', '+PageLinks +NotificationsOutgoing.Title +NotificationsIncoming.Title -journalPrivacy -journalPost +JournalEntries -contentArticles +SearchIndexes +NotificationsOutgoing.Feedback +NotificationsOutgoing.Comments +NotificationsIncoming.Feedback +NotificationsIncoming.Comments +FriendPing +NetworkNodes >NetworkNodes.Domain="appleseedproject.org" +SchemaVersions >SchemaVersions.Version="0.7.9" ' );

drop table `#__systemNodes`;
drop table `#__systemNodes`;
drop table `#__NodeDiscovery`;
54 changes: 0 additions & 54 deletions hooks/quicksocial/libraries/QuickSocial-0.1.0/quicknode.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,6 @@ public function __construct ( ) {
parent::__construct();
}

public function Discover ( $pTarget ) {

$fCreateLocalToken = $this->GetCallBack ( "CreateLocalToken" );

if ( !is_callable ( $fCreateLocalToken ) ) {
trigger_error("Invalid Callback: CreateLocalToken", E_USER_WARNING);
return ( false );
}

$token = @call_user_func ( $fCreateLocalToken, null, $pTarget );

$data = array (
"_social" => "true",
"_task" => "node.discover",
"_source" => QUICKSOCIAL_DOMAIN,
"_token" => $token
);

$result = $this->_Communicate ( $pTarget, $data );

return ( $result );
}

public function ReplyToDiscover ( ) {
$social = $this->_GET['_social'];
$task = $this->_GET['_task'];

if ( $social != "true" ) return ( false );
if ( $task != "node.discover" ) return ( false );

$source = $this->_GET['_source'];
$token = $this->_GET['_token'];

$verified = false;
if ( ( $source ) && ( $token ) ) {
$verified = $this->Verify ( null, $source, $token );
}

$fNodeInformation = $this->GetCallback ( "NodeInformation" );

if ( !is_callable ( $fNodeInformation ) ) $this->_Error ( "Invalid Callback: NodeInformation" );

$data = @call_user_func ( $fNodeInformation, $source, $verified );

if ( !is_array ( $data ) ) $this->_Error ( "Invalid Callback Return" );

$data['version'] = QUICKSOCIAL_VERSION;
$data['success'] = "true";
$data['error'] = "";

echo json_encode ( $data );
exit;
}

public function Synchronize ( $pTarget, $pDescription, $pMethods ) {

$fCreateLocalToken = $this->GetCallBack ( "CreateLocalToken" );
Expand Down
51 changes: 13 additions & 38 deletions hooks/quicksocial/quicksocial.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,6 @@ public function __construct ( ) {
parent::__construct();
}

public function SystemNodeDiscovery ( $pData = array() ) {

if (!class_exists ( 'cQuickNode' ) ) require ( ASD_PATH . 'hooks' . DS . 'quicksocial' . DS . 'libraries' . DS . 'QuickSocial-0.1.0' . DS . 'quicknode.php' );

// Set caching on by default.
$cache = $pData['cache'] ? isset ( $pData['cache'] ) : true;

if ( $cache ) {
$model = new cModel ( 'NodeDiscovery');
}

$node = new cQuickNode ();

$domain = $pData['domain'];

$node->SetCallback ( 'CheckLocalToken', array ( $this, '_CheckLocalToken' ) );
$node->SetCallback ( 'CreateLocalToken', array ( $this, '_CreateLocalToken' ) );

$node = $node->Discover ( $domain );

return ( $node );
}

public function EndSystemInitialize ( $pData = null ) {

// Bounce if requested.
Expand Down Expand Up @@ -136,16 +113,6 @@ public function EndSystemInitialize ( $pData = null ) {
$node->ReplyToSynchronize();
exit;
break;
case 'node.discover':
require ( ASD_PATH . 'hooks' . DS . 'quicksocial' . DS . 'libraries' . DS . 'QuickSocial-0.1.0' . DS . 'quicknode.php' );

$node = new cQuickNode ();
$node->SetCallback ( 'CheckRemoteToken', array ( $this, '_CheckRemoteToken' ) );
$node->SetCallback ( 'CreateRemoteToken', array ( $this, '_CreateRemoteToken' ) );
$node->SetCallback ( 'NodeInformation', array ( $this, '_NodeInformation' ) );
$node->ReplyToDiscover();
exit;
break;
case 'redirect':
require ( ASD_PATH . 'hooks' . DS . 'quicksocial' . DS . 'libraries' . DS . 'QuickSocial-0.1.0' . DS . 'quickredirect.php' );

Expand Down Expand Up @@ -231,8 +198,14 @@ public function OnLoginAuthenticate ( $pData ) {
$node->SetCallback ( 'CheckLocalToken', array ( $this, '_CheckLocalToken' ) );
$node->SetCallback ( 'CreateLocalToken', array ( $this, '_CreateLocalToken' ) );
$node->SetCallback ( 'LogNetworkRequest', array ( $this, '_LogNetworkRequest' ) );
$node->SetCallback ( 'LoadNodeNetwork', array ( $this, '_LoadNodeNetwork' ) );
$node->SetCallback ( 'NodeInformation', array ( $this, '_NodeInformation' ) );
$node->SetCallback ( 'StoreNodeNetwork', array ( $this, '_StoreNodeNetwork' ) );

$node = $node->Discover ( $domain );
$node_description = __ ( $this->GetSys ( 'Config' )->GetConfiguration ( 'node_description' ), array ( 'domain' => ASD_DOMAIN ) );
$node_methods = $this->GetSys ( 'Config' )->GetConfiguration ( 'node_methods' );

$node = $node->Synchronize ( $domain, $node_description, $node_methods );

if ( $node->success != 'true' ) {
$return = new stdClass();
Expand Down Expand Up @@ -1147,7 +1120,9 @@ public function UpdateNodeNetwork ( ) {

// 2. Loop through all nodes.
foreach ( $nodes as $n => $node ) {

// Check for regular expression characters, ? * ^ $
if ( preg_match ( '/[^A-Za-z0-9_\-\.]/', $node ) ) continue;

// 3. Contact nodes and recieve node list back.
$quickNode->Synchronize( $node, $node_description, $node_methods );

Expand Down Expand Up @@ -1282,7 +1257,7 @@ public function _StoreNodeNetwork ( $pSource, $pMethods, $pDescription, $pVersio
$model->Set ( 'Updated', NOW() );
$model->Set ( 'Contacted', NOW() );
$model->Set ( 'Version', null );
$model->Set ( 'Status', true );
$model->Set ( 'Status', false );
$model->Save();
}

Expand All @@ -1305,7 +1280,7 @@ public function _StoreNodeNetwork ( $pSource, $pMethods, $pDescription, $pVersio
$model->Set ( 'Updated', NOW() );
$model->Set ( 'Contacted', NOW() );
$model->Set ( 'Version', null );
$model->Set ( 'Status', true );
$model->Set ( 'Status', false );
$model->Save();
}

Expand Down Expand Up @@ -1335,7 +1310,7 @@ public function _StoreNodeNetwork ( $pSource, $pMethods, $pDescription, $pVersio
$model->Set ( 'Updated', NOW() );
$model->Set ( 'Contacted', NOW() );
$model->Set ( 'Version', null );
$model->Set ( 'Status', true );
$model->Set ( 'Status', false );
$model->Save();
}

Expand Down

0 comments on commit af47151

Please sign in to comment.