moveme: send and receive DFRN "relocate" message (WIP)
This commit is contained in:
parent
c51e057fe6
commit
dbc6cbe024
|
@ -2305,7 +2305,7 @@ function local_delivery($importer,$data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Currently unsupported - needs a lot of work
|
// Currently unsupported - needs a lot of work
|
||||||
$reloc = $feed->get_feed_tags( NAMESPACE_DFRN, 'relocate' );
|
$reloc = $feed->get_feed_tags( NAMESPACE_DFRN, 'relocate' );
|
||||||
if(isset($reloc[0]['child'][NAMESPACE_DFRN])) {
|
if(isset($reloc[0]['child'][NAMESPACE_DFRN])) {
|
||||||
|
@ -2315,23 +2315,71 @@ function local_delivery($importer,$data) {
|
||||||
$newloc['cid'] = $importer['id'];
|
$newloc['cid'] = $importer['id'];
|
||||||
$newloc['name'] = notags(unxmlify($base['name'][0]['data']));
|
$newloc['name'] = notags(unxmlify($base['name'][0]['data']));
|
||||||
$newloc['photo'] = notags(unxmlify($base['photo'][0]['data']));
|
$newloc['photo'] = notags(unxmlify($base['photo'][0]['data']));
|
||||||
|
$newloc['thumb'] = notags(unxmlify($base['thumb'][0]['data']));
|
||||||
|
$newloc['micro'] = notags(unxmlify($base['micro'][0]['data']));
|
||||||
$newloc['url'] = notags(unxmlify($base['url'][0]['data']));
|
$newloc['url'] = notags(unxmlify($base['url'][0]['data']));
|
||||||
$newloc['request'] = notags(unxmlify($base['request'][0]['data']));
|
$newloc['request'] = notags(unxmlify($base['request'][0]['data']));
|
||||||
$newloc['confirm'] = notags(unxmlify($base['confirm'][0]['data']));
|
$newloc['confirm'] = notags(unxmlify($base['confirm'][0]['data']));
|
||||||
$newloc['notify'] = notags(unxmlify($base['notify'][0]['data']));
|
$newloc['notify'] = notags(unxmlify($base['notify'][0]['data']));
|
||||||
$newloc['poll'] = notags(unxmlify($base['poll'][0]['data']));
|
$newloc['poll'] = notags(unxmlify($base['poll'][0]['data']));
|
||||||
$newloc['site-pubkey'] = notags(unxmlify($base['site-pubkey'][0]['data']));
|
$newloc['site-pubkey'] = notags(unxmlify($base['site-pubkey'][0]['data']));
|
||||||
$newloc['pubkey'] = notags(unxmlify($base['pubkey'][0]['data']));
|
/*$newloc['pubkey'] = notags(unxmlify($base['pubkey'][0]['data']));
|
||||||
$newloc['prvkey'] = notags(unxmlify($base['prvkey'][0]['data']));
|
$newloc['prvkey'] = notags(unxmlify($base['prvkey'][0]['data']));*/
|
||||||
|
|
||||||
|
log("items:relocate contact ".print_r($newloc, true), LOGGER_DEBUG);
|
||||||
|
|
||||||
|
// update contact
|
||||||
|
$r = q("SELECT photo, url FROM contact WHERE WHERE id=%d AND uid=%d;",
|
||||||
|
intval($importer['importer_uid']),
|
||||||
|
intval($importer['id']));
|
||||||
|
$old = $r[0];
|
||||||
|
|
||||||
|
$x = q("UPDATE contact SET
|
||||||
|
name = '%s',
|
||||||
|
photo = '%s',
|
||||||
|
thumb = '%s',
|
||||||
|
micro = '%s',
|
||||||
|
url = '%s',
|
||||||
|
request = '%s',
|
||||||
|
confirm = '%s',
|
||||||
|
notify = '%s',
|
||||||
|
poll = '%s',
|
||||||
|
site-pubkey = '%s'
|
||||||
|
WHERE id=%d AND uid=%d;",
|
||||||
|
dbesc($newloc['name']),
|
||||||
|
dbesc($newloc['photo']),
|
||||||
|
dbesc($newloc['thumb']),
|
||||||
|
dbesc($newloc['micro']),
|
||||||
|
dbesc($newloc['url']),
|
||||||
|
dbesc($newloc['request']),
|
||||||
|
dbesc($newloc['confirm']),
|
||||||
|
dbesc($newloc['notify']),
|
||||||
|
dbesc($newloc['poll']),
|
||||||
|
dbesc($newloc['site-pubkey']),
|
||||||
|
intval($importer['importer_uid']),
|
||||||
|
intval($importer['id']));
|
||||||
|
|
||||||
|
// update items
|
||||||
|
$fields = array(
|
||||||
|
'owner-link' => array($old['url'], $newloc['url']),
|
||||||
|
'author-link' => array($old['url'], $newloc['url']),
|
||||||
|
'owner-avatar' => array($old['photo'], $newloc['photo']),
|
||||||
|
'author-avatar' => array($old['photo'], $newloc['photo']),
|
||||||
|
);
|
||||||
|
foreach ($fields as $n=>$f)
|
||||||
|
$x = q("UPDATE item SET `%s`='%s' WHERE `%s`='%s' AND uid=%d",
|
||||||
|
$n, dbesc($f[1]),
|
||||||
|
$n, dbesc($f[0]),
|
||||||
|
intval($importer['importer_uid']));
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// merge with current record, current contents have priority
|
// merge with current record, current contents have priority
|
||||||
// update record, set url-updated
|
// update record, set url-updated
|
||||||
// update profile photos
|
// update profile photos
|
||||||
// schedule a scan?
|
// schedule a scan?
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// handle friend suggestion notification
|
// handle friend suggestion notification
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ function notifier_run($argv, $argc){
|
||||||
$expire = false;
|
$expire = false;
|
||||||
$mail = false;
|
$mail = false;
|
||||||
$fsuggest = false;
|
$fsuggest = false;
|
||||||
|
$relocate = false;
|
||||||
$top_level = false;
|
$top_level = false;
|
||||||
$recipients = array();
|
$recipients = array();
|
||||||
$url_recipients = array();
|
$url_recipients = array();
|
||||||
|
@ -134,6 +135,11 @@ function notifier_run($argv, $argc){
|
||||||
$recipients[] = $suggest[0]['cid'];
|
$recipients[] = $suggest[0]['cid'];
|
||||||
$item = $suggest[0];
|
$item = $suggest[0];
|
||||||
}
|
}
|
||||||
|
elseif($cmd === 'relocate') {
|
||||||
|
$normal_mode = false;
|
||||||
|
$relocate = true;
|
||||||
|
$uid = $item_id;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// find ancestors
|
// find ancestors
|
||||||
|
@ -404,6 +410,29 @@ function notifier_run($argv, $argc){
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
elseif($relocate) {
|
||||||
|
$public_message = false; // suggestions are not public
|
||||||
|
|
||||||
|
$sugg_template = get_markup_template('atom_relocate.tpl');
|
||||||
|
|
||||||
|
$atom .= replace_macros($sugg_template, array(
|
||||||
|
'$name' => xmlfy($owner['name']),
|
||||||
|
'$photo' => xmlfy($owner['photo']),
|
||||||
|
'$thumb' => xmlfy($owner['thumb']),
|
||||||
|
'$micro' => xmlfy($owner['micro']),
|
||||||
|
'$url' => xmlfy($owner['url']),
|
||||||
|
'$request' => xmlfy($owner['request']),
|
||||||
|
'$confirm' => xmlfy($owner['confirm']),
|
||||||
|
'$notify' => xmlfy($owner['notify']),
|
||||||
|
'$poll' => xmlfy($owner['poll']),
|
||||||
|
'$site-pubkey' => xmlfy(get_config('system','site_pubkey')),
|
||||||
|
//'$pubkey' => xmlfy($owner['pubkey']),
|
||||||
|
//'$prvkey' => xmlfy($owner['prvkey']),
|
||||||
|
));
|
||||||
|
$recipients_relocate = q("SELECT * FROM contacts WHERE uid = %d AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if($followup) {
|
if($followup) {
|
||||||
foreach($items as $item) { // there is only one item
|
foreach($items as $item) { // there is only one item
|
||||||
|
@ -479,9 +508,12 @@ function notifier_run($argv, $argc){
|
||||||
else
|
else
|
||||||
$recip_str = implode(', ', $recipients);
|
$recip_str = implode(', ', $recipients);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ",
|
if ($relocate)
|
||||||
dbesc($recip_str)
|
$r = $recipients_relocate;
|
||||||
);
|
else
|
||||||
|
$r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ",
|
||||||
|
dbesc($recip_str)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
require_once('include/salmon.php');
|
require_once('include/salmon.php');
|
||||||
|
|
|
@ -125,7 +125,7 @@ function import_account(&$a, $file) {
|
||||||
if ($contact['uid'] == $olduid && $contact['self'] == '0') {
|
if ($contact['uid'] == $olduid && $contact['self'] == '0') {
|
||||||
switch ($contact['network']){
|
switch ($contact['network']){
|
||||||
case NETWORK_DFRN:
|
case NETWORK_DFRN:
|
||||||
// send moved message
|
// send relocate message (below)
|
||||||
break;
|
break;
|
||||||
case NETWORK_ZOT:
|
case NETWORK_ZOT:
|
||||||
// TODO handle zot network
|
// TODO handle zot network
|
||||||
|
@ -226,10 +226,12 @@ function import_account(&$a, $file) {
|
||||||
logger("uimport:insert pconfig ".$pconfig['id']. " : ERROR : ".last_error(), LOGGER_NORMAL);
|
logger("uimport:insert pconfig ".$pconfig['id']. " : ERROR : ".last_error(), LOGGER_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send relocate messages
|
||||||
|
proc_run('php', 'include/notifier.php', 'relocate' , $newuid);
|
||||||
|
|
||||||
info(t("Done. You can now login with your username and password"));
|
info(t("Done. You can now login with your username and password"));
|
||||||
goaway( $a->get_baseurl() ."/login");
|
goaway( $a->get_baseurl() ."/login");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
17
view/atom_relocate.tpl
Normal file
17
view/atom_relocate.tpl
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
<dfrn:relocate>
|
||||||
|
|
||||||
|
<dfrn:url>$url</dfrn:url>
|
||||||
|
<dfrn:name>$name</dfrn:name>
|
||||||
|
<dfrn:photo>$photo</dfrn:photo>
|
||||||
|
<dfrn:photo>$thumb</dfrn:photo>
|
||||||
|
<dfrn:photo>$micro</dfrn:photo>
|
||||||
|
<dfrn:request>$request</dfrn:request>
|
||||||
|
<dfrn:confirm>$confirm</dfrn:confirm>
|
||||||
|
<dfrn:notify>$notify</dfrn:notify>
|
||||||
|
<dfrn:poll>$poll</dfrn:poll>
|
||||||
|
<dfrn:site-pubkey>$site-pubkey</dfrn:site-pubkey>
|
||||||
|
|
||||||
|
|
||||||
|
</dfrn:relocate>
|
||||||
|
|
Loading…
Reference in a new issue