diff options
Diffstat (limited to 'plugins/shotwell-publishing')
-rw-r--r-- | plugins/shotwell-publishing/PhotosPublisher.vala | 22 | ||||
-rw-r--r-- | plugins/shotwell-publishing/YouTubePublishing.vala | 3 |
2 files changed, 19 insertions, 6 deletions
diff --git a/plugins/shotwell-publishing/PhotosPublisher.vala b/plugins/shotwell-publishing/PhotosPublisher.vala index b592317..67c3ecb 100644 --- a/plugins/shotwell-publishing/PhotosPublisher.vala +++ b/plugins/shotwell-publishing/PhotosPublisher.vala @@ -111,6 +111,7 @@ internal class PublishingParameters { } private class MediaCreationTransaction : Publishing.RESTSupport.GooglePublisher.AuthenticatedTransaction { + // SCOPE: photoslibrary.appendonly private const string ENDPOINT_URL = "https://photoslibrary.googleapis.com/v1/mediaItems:batchCreate"; private string[] upload_tokens; private string[] titles; @@ -154,6 +155,7 @@ private class MediaCreationTransaction : Publishing.RESTSupport.GooglePublisher. } private class AlbumCreationTransaction : Publishing.RESTSupport.GooglePublisher.AuthenticatedTransaction { + // SCOPE: photoslibrary.appendonly private const string ENDPOINT_URL = "https://photoslibrary.googleapis.com/v1/albums"; private string title; @@ -179,6 +181,7 @@ private class AlbumCreationTransaction : Publishing.RESTSupport.GooglePublisher. } private class AlbumDirectoryTransaction : Publishing.RESTSupport.GooglePublisher.AuthenticatedTransaction { + // SCOPE: photoslibrary.readonly.appcreateddata private const string ENDPOINT_URL = "https://photoslibrary.googleapis.com/v1/albums"; public AlbumDirectoryTransaction(Publishing.RESTSupport.GoogleSession session, string? token) { @@ -244,8 +247,15 @@ public class Publisher : Publishing.RESTSupport.GooglePublisher { if (!is_running()) return; + var json = Json.from_string (txn.get_response()); var object = json.get_object (); + // Work-around for Google sometimes sending an empty JSON object '{}' instead of + // not setting the nextPageToken on the previous page + if (object.get_size() == 0) { + break; + } + if (!object.has_member ("albums")) { throw new Spit.Publishing.PublishingError.MALFORMED_RESPONSE("Album fetch did not contain expected data"); } @@ -279,7 +289,10 @@ public class Publisher : Publishing.RESTSupport.GooglePublisher { debug("EVENT: fetching album information failed; response = '%s'.", txn.get_response()); - if (txn.get_status_code() == 403 || txn.get_status_code() == 404) { + if (txn.get_status_code() == 403) { + debug("Lacking permission to download album list, showing publishing options anyway"); + show_publishing_options_pane(); + } else if (txn.get_status_code() == 404) { do_logout(); } else { // If we get any other kind of error, we can't recover, so just post it to the user @@ -345,10 +358,13 @@ public class Publisher : Publishing.RESTSupport.GooglePublisher { yield do_upload(); } catch (Error err) { - debug("EVENT: creating album failed; response = '%s'.", + debug("EVENT: creating album failed; status = '%u', response = '%s'.", txn.get_status_code(), txn.get_response()); - if (txn.get_status_code() == 403 || txn.get_status_code() == 404) { + if (txn.get_status_code() == 403) { + get_host().install_static_message_pane(_("Could not create album, Shotwell is lacking permission to do so. Please re-authenticate and grant Shotwell the required permission to create new media and albums"), + Spit.Publishing.PluginHost.ButtonMode.CLOSE); + } else if (txn.get_status_code() == 404) { do_logout(); } else { // If we get any other kind of error, we can't recover, so just post it to the user diff --git a/plugins/shotwell-publishing/YouTubePublishing.vala b/plugins/shotwell-publishing/YouTubePublishing.vala index 88218cc..13e4afd 100644 --- a/plugins/shotwell-publishing/YouTubePublishing.vala +++ b/plugins/shotwell-publishing/YouTubePublishing.vala @@ -44,9 +44,6 @@ public class YouTubeService : Object, Spit.Pluggable, Spit.Publishing.Service { namespace Publishing.YouTube { -private const string DEVELOPER_KEY = - "AIzaSyB6hLnm0n5j8Y6Bkvh9bz3i8ADM2bJdYeY"; - private enum PrivacySetting { PUBLIC, UNLISTED, |