Fix support for ownyourgram, hopefully

This commit is contained in:
Jonny Barnes 2017-06-11 20:54:10 +01:00
parent 2cd8a2c110
commit 2d7aee25c6
6 changed files with 112 additions and 2 deletions

View file

@ -3,7 +3,7 @@
declare(strict_types=1);
namespace App\Services;
use Log;
use App\{Media, Note, Place};
use App\Jobs\{SendWebMentions, SyndicateToFacebook, SyndicateToTwitter};
@ -17,6 +17,7 @@ class NoteService
*/
public function createNote(array $data): Note
{
Log::info($data);
//check the input
if (array_key_exists('content', $data) === false) {
throw new \Exception('No content defined'); //we cant fudge the data
@ -63,6 +64,7 @@ class NoteService
$place = Place::where('foursquare', $data['checkin'])->first();
if ($place !== null) {
$note->place()->associate($place);
$note->swarm_url = $data['swarm-url'];
}
}
@ -84,12 +86,15 @@ class NoteService
$media = Media::where('path', ltrim($path, '/'))->firstOrFail();
} else {
$media = Media::firstOrNew(['path' => $photo]);
// currently assuming this is a photo from Swarm
// currently assuming this is a photo from Swarm or OwnYourGram
$media->type = 'image';
$media->save();
}
$note->media()->save($media);
}
if (array_key_exists('instagram-url', $data)) {
$note->instagram_url = $data['instagram-url'];
}
}
$note->save();