-
Notifications
You must be signed in to change notification settings - Fork 6
Added some debugging for posting instagram image carousels. #1394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
geoff-maddock
wants to merge
1
commit into
main
Choose a base branch
from
dev-1388-event-instagram-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1548,7 +1548,7 @@ public function postCarouselToInstagram(int $id, Instagram $instagram): Redirect | |||||||||||||||||
|
||||||||||||||||||
Log::info('Carousel photo uploaded: '.$id); | ||||||||||||||||||
|
||||||||||||||||||
// add other photos related to the event to the carousel | ||||||||||||||||||
// // add other photos related to the event to the carousel | ||||||||||||||||||
foreach ($event->getOtherPhotos() as $otherPhotos) { | ||||||||||||||||||
$imageUrl = Storage::disk('external')->url($otherPhotos->getStoragePath()); | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -1579,7 +1579,7 @@ public function postCarouselToInstagram(int $id, Instagram $instagram): Redirect | |||||||||||||||||
Log::info('Carousel photo uploaded: '.$id); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// only do this if there are any other related photos | ||||||||||||||||||
// // only do this if there are any other related photos | ||||||||||||||||||
foreach ($event->entities as $entity) { | ||||||||||||||||||
foreach ($entity->photos as $photo) { | ||||||||||||||||||
if ($photo->is_primary) { | ||||||||||||||||||
|
@@ -1612,6 +1612,10 @@ public function postCarouselToInstagram(int $id, Instagram $instagram): Redirect | |||||||||||||||||
|
||||||||||||||||||
$igContainerIds[] = $igContainerId; | ||||||||||||||||||
Log::info('Added container id: '.$igContainerId); | ||||||||||||||||||
} else { | ||||||||||||||||||
flash()->error('Error', 'Photo is not primary'); | ||||||||||||||||||
|
||||||||||||||||||
return back(); | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
@@ -1620,22 +1624,24 @@ public function postCarouselToInstagram(int $id, Instagram $instagram): Redirect | |||||||||||||||||
try { | ||||||||||||||||||
$igCarouselId = $instagram->createCarousel($igContainerIds, $caption); | ||||||||||||||||||
} catch (Exception $e) { | ||||||||||||||||||
flash()->error('Error', 'There was an error posting carousel to Instagram. Please try again.'); | ||||||||||||||||||
Log::info('Error creating carousel'); | ||||||||||||||||||
// transform the igContainerIds into a string | ||||||||||||||||||
$igContainerIdsString = implode(', ', $igContainerIds); | ||||||||||||||||||
flash()->error('Error', 'There was an error posting carousel to Instagram. Unable to create carousel. Please try again. Ids: '.count($igContainerIds).' Container ids: '.$igContainerIdsString.' caption: '.substr($caption, 0, 5)); | ||||||||||||||||||
Log::info('Error creating carousel '.$e->getMessage()); | ||||||||||||||||||
Comment on lines
+1627
to
+1630
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The flash error message now includes container IDs and a caption substring which may expose sensitive or internal debugging information. Consider logging these details securely and providing a user-friendly error message.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
return back(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// check the container status every 5 seconds until status_code is FINISHED | ||||||||||||||||||
if ($instagram->checkStatus($igCarouselId) === false) { | ||||||||||||||||||
flash()->error('Error', 'There was an error posting to Instagram. Please try again.'); | ||||||||||||||||||
flash()->error('Error', 'There was an error posting to Instagram. Unable to check status. Please try again.'); | ||||||||||||||||||
|
||||||||||||||||||
return back(); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
// pubish the image | ||||||||||||||||||
$result = $instagram->publishMedia($igCarouselId); | ||||||||||||||||||
if ($result === false) { | ||||||||||||||||||
flash()->error('Error', 'There was an error posting to Instagram. Please try again.'); | ||||||||||||||||||
flash()->error('Error', 'There was an error posting to Instagram. Unable to publish image. Please try again.'); | ||||||||||||||||||
|
||||||||||||||||||
return back(); | ||||||||||||||||||
} | ||||||||||||||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The else branch returns early when encountering a non-primary photo. If non-primary photos might be expected, consider processing remaining photos instead of exiting immediately.
Copilot uses AI. Check for mistakes.