Browse Source

sql error

zotlabs 11 months ago
parent
commit
cdee25ea1b
3 changed files with 98 additions and 29 deletions
  1. 92 23
      Zotlabs/Lib/Activity.php
  2. 1 1
      Zotlabs/Lib/Libsync.php
  3. 5 5
      library/jsonld/jsonld.php

+ 92 - 23
Zotlabs/Lib/Activity.php

@@ -1590,24 +1590,37 @@ class Activity {
 			];
 
 			$mps = [];
-			if(array_key_exists('url',$act->obj) && is_array($act->obj['url'])) {
-				foreach($act->obj['url'] as $vurl) {
-					if(in_array($vurl['mimeType'], $vtypes)) {
-						if(! array_key_exists('width',$vurl)) {
-							$vurl['width'] = 0;
+			$ptr = null;
+
+			if(array_key_exists('url',$act->obj)) {
+				if(is_array($act->obj['url'])) {
+					if(array_key_exists(0,$act->obj['url'])) {				
+						$ptr = $act->obj['url'];
+					}
+					else {
+						$ptr = [ $act->obj['url'] ];
+					}
+					foreach($ptr as $vurl) {
+						if(in_array($vurl['mediaType'], $vtypes)) {
+							if(! array_key_exists('width',$vurl)) {
+								$vurl['width'] = 0;
+							}
+							$mps[] = $vurl;
 						}
-						$mps[] = $vurl;
 					}
 				}
-			}
-			if($mps) {
-				usort($mps,[ __CLASS__, 'vid_sort' ]);
-				foreach($mps as $m) {
-					if(intval($m['width']) < 500) {
-						$s['body'] .= "\n\n" . '[video]' . $m['href'] . '[/video]';
-						break;
+				if($mps) {
+					usort($mps,[ __CLASS__, 'vid_sort' ]);
+					foreach($mps as $m) {
+						if(intval($m['width']) < 500) {
+							$s['body'] .= "\n\n" . '[video]' . $m['href'] . '[/video]';
+							break;
+						}
 					}
 				}
+				elseif(is_string($act->obj['url'])) {
+					$s['body'] .= "\n\n" . '[video]' . $act->obj['url'] . '[/video]';
+				}
 			}
 		}
 
@@ -1619,28 +1632,84 @@ class Activity {
 				'audio/wav'
 			];
 
-			if(array_key_exists('url',$act->obj) && is_array($act->obj['url'])) {
-				foreach($act->obj['url'] as $vurl) {
-					if(in_array($vurl['mimeType'], $atypes)) {
-						$s['body'] .= "\n\n" . '[audio]' . $vurl['href'] . '[/audio]';
-						break;
+			$ptr = null;
+
+			if(array_key_exists('url',$act->obj)) {
+				if(is_array($act->obj['url'])) {
+					if(array_key_exists(0,$act->obj['url'])) {				
+						$ptr = $act->obj['url'];
 					}
+					else {
+						$ptr = [ $act->obj['url'] ];
+					}
+					foreach($ptr as $vurl) {
+						if(in_array($vurl['mediaType'], $atypes)) {
+							$s['body'] .= "\n\n" . '[audio]' . $vurl['href'] . '[/audio]';
+							break;
+						}
+					}
+				}
+				elseif(is_string($act->obj['url'])) {
+					$s['body'] .= "\n\n" . '[audio]' . $act->obj['url'] . '[/audio]';
 				}
 			}
+
 		}
 
 		if($act->obj['type'] === 'Image') {
-			if(array_key_exists('url',$act->obj) && is_array($act->obj['url'])) {
-				foreach($act->obj['url'] as $vurl) {
-					if(strpos($s['body'],$vurl['href']) === false) {
-						$s['body'] .= "\n\n" . '[zmg]' . $vurl['href'] . '[/zmg]';
-						break;
+
+			$ptr = null;
+
+			if(array_key_exists('url',$act->obj)) {
+				if(is_array($act->obj['url'])) {
+					if(array_key_exists(0,$act->obj['url'])) {				
+						$ptr = $act->obj['url'];
+					}
+					else {
+						$ptr = [ $act->obj['url'] ];
+					}
+					foreach($ptr as $vurl) {
+						if(strpos($s['body'],$vurl['href']) === false) {
+							$s['body'] .= "\n\n" . '[zmg]' . $vurl['href'] . '[/zmg]';
+							break;
+						}
+					}
+				}
+				elseif(is_string($act->obj['url'])) {
+					if(strpos($s['body'],$act->obj['url']) === false) {
+						$s['body'] .= "\n\n" . '[zmg]' . $act->obj['url'] . '[/zmg]';
 					}
 				}
 			}
 		}
 
+		if(in_array($act->obj['type'],[ 'Note','Article' ])) {
+			$ptr = null;
+
+			if(array_key_exists('url',$act->obj)) {
+				if(is_array($act->obj['url'])) {
+					if(array_key_exists(0,$act->obj['url'])) {				
+						$ptr = $act->obj['url'];
+					}
+					else {
+						$ptr = [ $act->obj['url'] ];
+					}
+					foreach($ptr as $vurl) {
+						if(array_key_exists('mediaType',$vurl) && $vurl['mediaType'] === 'text/plain') {
+							$s['plink'] = $vurl['href'];
+							break;
+						}
+					}
+				}
+				elseif(is_string($act->obj['url'])) {
+					$s['plink'] = $act->obj['url'];
+				}
+			}
+		}
 
+		if(! $s['plink']) {
+			$s['plink'] = $s['mid'];
+		}
 
 		if($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips)))
 			$s['item_private'] = 1;

+ 1 - 1
Zotlabs/Lib/Libsync.php

@@ -49,7 +49,7 @@ class Libsync {
 		if(intval($channel['channel_removed']))
 			return;
 
-		$h = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_netwoor = 'zot6' and hubloc_deleted = 0",
+		$h = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_network = 'zot6' and hubloc_deleted = 0",
 			dbesc(($keychange) ? $packet['keychange']['old_hash'] : $channel['channel_hash'])
 		);
 

+ 5 - 5
library/jsonld/jsonld.php

@@ -4301,7 +4301,7 @@ class JsonLdProcessor {
     sort($nquads);
 
     // cache and return hashed quads
-    $hash = $bnodes->{$id}->hash = sha1(implode($nquads));
+    $hash = $bnodes->{$id}->hash = hash('sha256',implode($nquads));
     return $hash;
   }
 
@@ -4320,8 +4320,8 @@ class JsonLdProcessor {
    * @return stdClass the hash and path namer used.
    */
   protected function _hashPaths($id, $bnodes, $namer, $path_namer) {
-    // create SHA-1 digest
-    $md = hash_init('sha1');
+    // create digest
+    $md = hash_init('sha256');
 
     // group adjacent bnodes by hash, keep properties and references separate
     $groups = new stdClass();
@@ -4350,7 +4350,7 @@ class JsonLdProcessor {
         }
 
         // hash direction, property, and bnode name/hash
-        $group_md = hash_init('sha1');
+        $group_md = hash_init('sha256');
         hash_update($group_md, $direction);
         hash_update($group_md, $quad->predicate->value);
         hash_update($group_md, $name);
@@ -4433,7 +4433,7 @@ class JsonLdProcessor {
       $path_namer = $chosen_namer;
     }
 
-    // return SHA-1 hash and path namer
+    // return hash and path namer
     return (object)array(
       'hash' => hash_final($md), 'pathNamer' => $path_namer);
   }