diff options
author | Friendika <info@friendika.com> | 2011-09-18 20:17:44 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-09-18 20:17:44 -0700 |
commit | 48ee3fa3b9c540185fb3691ce6a971dd2cf1fd68 (patch) | |
tree | 14eeaaf7b0204e06e9636fbd1fc215fb0ec0c7b3 | |
parent | 5b3f6459392ba6f417cfc5cb0d38094c009c6913 (diff) | |
download | volse-hubzilla-48ee3fa3b9c540185fb3691ce6a971dd2cf1fd68.tar.gz volse-hubzilla-48ee3fa3b9c540185fb3691ce6a971dd2cf1fd68.tar.bz2 volse-hubzilla-48ee3fa3b9c540185fb3691ce6a971dd2cf1fd68.zip |
build diaspora public (batch) message
-rw-r--r-- | boot.php | 1 | ||||
-rw-r--r-- | include/diaspora.php | 46 |
2 files changed, 47 insertions, 0 deletions
@@ -164,6 +164,7 @@ define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' ); define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' ); define ( 'ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' ); define ( 'ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event' ); +define ( 'ACTIVITY_OBJ_TAGTERM', NAMESPACE_DFRN . '/tagterm' ); /** * item weight for query ordering diff --git a/include/diaspora.php b/include/diaspora.php index 313324a16..a6f3002b9 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -103,6 +103,52 @@ function get_diaspora_key($uri) { } +function diaspora_pubmsg_build($msg,$user,$contact,$prvkey,$pubkey) { + $a = get_app(); + + logger('diaspora_pubmsg_build: ' . $msg, LOGGER_DATA); + + + $handle = $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); + + $b64_data = base64_encode($msg); + $b64url_data = base64url_encode($b64_data); + + $data = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data); + + $type = 'application/xml'; + $encoding = 'base64url'; + $alg = 'RSA-SHA256'; + + $signable_data = $data . '.' . base64url_encode($type) . '.' + . base64url_encode($encoding) . '.' . base64url_encode($alg) ; + + $signature = rsa_sign($signable_data,$prvkey); + $sig = base64url_encode($signature); + +$magic_env = <<< EOT +<?xml version='1.0' encoding='UTF-8'?> +<diaspora xmlns="https://joindiaspora.org/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env" > + <header> + <author_id>$handle</author_id> + </header> + <me:env> + <me:encoding>base64url</me:encoding> + <me:alg>RSA-SHA256</me:alg> + <me:data type="application/xml">$data</me:data> + <me:sig>$sig</me:sig> + </me:env> +</diaspora> +EOT; + + logger('diaspora_pubmsg_build: magic_env: ' . $magic_env, LOGGER_DATA); + return $magic_env; + +} + + + + function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) { $a = get_app(); |