We now transmit location and application as well.
This commit is contained in:
		
					parent
					
						
							
								8b9aa80aad
							
						
					
				
			
			
				commit
				
					
						f60468677e
					
				
			
		
					 2 changed files with 48 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -25,6 +25,10 @@ use Friendica\Util\DateTimeFormat;
 | 
			
		|||
 * - Event
 | 
			
		||||
 * - Undo Announce
 | 
			
		||||
 *
 | 
			
		||||
 * Missing object fields:
 | 
			
		||||
 * - Location
 | 
			
		||||
 * - Generator
 | 
			
		||||
 *
 | 
			
		||||
 * Check what this is meant to do:
 | 
			
		||||
 * - Add
 | 
			
		||||
 * - Block
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,6 +24,7 @@ use Friendica\Object\Image;
 | 
			
		|||
use Friendica\Protocol\ActivityPub;
 | 
			
		||||
use Friendica\Protocol\Diaspora;
 | 
			
		||||
use Friendica\Core\Cache;
 | 
			
		||||
use Friendica\Util\Map;
 | 
			
		||||
 | 
			
		||||
require_once 'include/api.php';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -32,10 +33,6 @@ require_once 'include/api.php';
 | 
			
		|||
 *
 | 
			
		||||
 * To-Do:
 | 
			
		||||
 *
 | 
			
		||||
 * Missing object fields:
 | 
			
		||||
 * - service (App)
 | 
			
		||||
 * - location
 | 
			
		||||
 *
 | 
			
		||||
 * Missing object types:
 | 
			
		||||
 * - Event
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -600,6 +597,40 @@ class Transmitter
 | 
			
		|||
		return $data;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Creates a location entry for a given item array
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param array $item
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return array with location array
 | 
			
		||||
	 */
 | 
			
		||||
	private static function createLocation($item)
 | 
			
		||||
	{
 | 
			
		||||
		$location = ['type' => 'Place'];
 | 
			
		||||
 | 
			
		||||
		if (!empty($item['location'])) {
 | 
			
		||||
			$location['name'] = $item['location'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$coord = [];
 | 
			
		||||
 | 
			
		||||
		if (empty($item['coord'])) {
 | 
			
		||||
			$coord = Map::getCoordinates($item['location']);
 | 
			
		||||
		} else {
 | 
			
		||||
			$coords = explode(' ', $item['coord']);
 | 
			
		||||
			if (count($coords) == 2) {
 | 
			
		||||
				$coord = ['lat' => $coords[0], 'lon' => $coords[1]];
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!empty($coord['lat']) && !empty($coord['lon'])) {
 | 
			
		||||
			$location['latitude'] = $coord['lat'];
 | 
			
		||||
			$location['longitude'] = $coord['lon'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $location;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Returns a tag array for a given item array
 | 
			
		||||
	 *
 | 
			
		||||
| 
						 | 
				
			
			@ -801,6 +832,15 @@ class Transmitter
 | 
			
		|||
 | 
			
		||||
		$data['attachment'] = self::createAttachmentList($item, $type);
 | 
			
		||||
		$data['tag'] = self::createTagList($item);
 | 
			
		||||
 | 
			
		||||
		if (!empty($item['coord']) || !empty($item['location'])) {
 | 
			
		||||
			$data['location'] = self::createLocation($item);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!empty($item['app'])) {
 | 
			
		||||
			$data['generator'] = ['type' => 'Application', 'name' => $item['app']];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$data = array_merge($data, self::createPermissionBlockForItem($item));
 | 
			
		||||
 | 
			
		||||
		return $data;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue