Fix support for ownyourgram, hopefully
This commit is contained in:
parent
2cd8a2c110
commit
2d7aee25c6
6 changed files with 112 additions and 2 deletions
|
@ -87,6 +87,7 @@ class MicropubController extends Controller
|
|||
//create checkin place
|
||||
if (array_key_exists('checkin', $request->input('properties'))) {
|
||||
$data['checkin'] = $request->input('properties.checkin.0.properties.url.0');
|
||||
$data['swarm-url'] = $request->input('properties.syndication.0');
|
||||
try {
|
||||
$this->placeService->createPlaceFromCheckin($request->input('properties.checkin.0'));
|
||||
} catch (\Exception $e) {
|
||||
|
@ -143,6 +144,9 @@ class MicropubController extends Controller
|
|||
$data['photo'][] = $photo;
|
||||
}
|
||||
}
|
||||
if (starts_with($request->input('properties.syndication.0'), 'https://www.instagram.com')) {
|
||||
$data['instagram-url'] = $request->input('properties.syndication.0');
|
||||
}
|
||||
}
|
||||
try {
|
||||
$note = $this->noteService->createNote($data);
|
||||
|
|
|
@ -13,6 +13,13 @@ class Media extends Model
|
|||
*/
|
||||
protected $table = 'media_endpoint';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['path'];
|
||||
|
||||
/**
|
||||
* Get the note that owns this media.
|
||||
*/
|
||||
|
|
|
@ -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 can’t 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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue