Merge lp:~systemdisc/shutter/imgur-fix into lp:shutter

Proposed by Timothy Zorn on 2017-01-03
Status: Merged
Merged at revision: 1279
Proposed branch: lp:~systemdisc/shutter/imgur-fix
Merge into: lp:shutter
Diff against target: 341 lines (+190/-62)
4 files modified
bin/shutter (+5/-2)
share/shutter/resources/modules/Shutter/App/Common.pm (+1/-1)
share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm (+4/-0)
share/shutter/resources/system/upload_plugins/upload/Imgur.pm (+180/-59)
To merge this branch: bzr merge lp:~systemdisc/shutter/imgur-fix
Reviewer Review Type Date Requested Status
Mario Kemper (Romario) 2017-01-03 Approve on 2017-08-01
Michael Kogan Approve on 2017-01-28
Manuel Razzari (community) Approve on 2017-01-13
Review via email: mp+313977@code.launchpad.net

Description of the change

I fixed Imgur Guest uploading and added Imgur OAuth uploading. Feel free to swap out the Client ID and Client Secret for your own imgur app registered here: https://api.imgur.com/oauth2/addclient (OAuth 2 authorization without a callback URL).

To post a comment you must log in.
Manuel Razzari (manael) wrote :

This worked for me!

Would be great if guest uploads had a wizard to create a config file.

For anyone who needs it:

1. Register here: https://api.imgur.com/oauth2/addclient (OAuth 2 authorization without a callback URL).
2. Create ~/.imgur-api-config (this will be a JSON config file in your home dir)
3. Populate it with the imgur keys from step 1:

{
"client_id": "xxxxxxxxxxxxxxx",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}

review: Approve
Timothy Zorn (systemdisc) wrote :

> This worked for me!
>
> Would be great if guest uploads had a wizard to create a config file.

There's not need for guest uploads to create a config file, since the user does not need to authenticate themselves.

>
> For anyone who needs it:
>
> 1. Register here: https://api.imgur.com/oauth2/addclient (OAuth 2
> authorization without a callback URL).
> 2. Create ~/.imgur-api-config (this will be a JSON config file in your home
> dir)
> 3. Populate it with the imgur keys from step 1:
>
> {
> "client_id": "xxxxxxxxxxxxxxx",
> "client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> }

This is incorrect. The client_id and client_secret should be set by the software, not the end user. I was letting the owner of this repository know how to get their own client_id and client_secret if they wanted it.

Manuel Razzari (manael) wrote :

> There's not need for guest uploads to create a config file, since the user
> does not need to authenticate themselves.

Apologies for the confusion. Maybe it should've been a comment on #1565048.

My note was aimed at other people trying to use this Shutter feature, since it hasn't been updated in 2+ years, and your patch does fix it.

Since I had to get my own imgur keys for it to work, I wanted to let people know how to do it without having to review the code :)

Michael Kogan (michael-kogan) wrote :

Since it is quite improbably that Mario will review this any time soon: Is there any way to make the guest upload work without user interaction? I would like to include this patch into Shutter's Arch Linux package and get stuck with a connection error.

Timothy Zorn (systemdisc) wrote :

Guest uploading to Imgur should work without anything more than selecting Imgur Guest. Can you provide more details on the issue you're having?

Michael Kogan (michael-kogan) wrote :

I'm getting this error in a popup window when trying Imgur guest uploading:

Invalid client_id: Maybe you or Imgur revoked or expired an access token. Please close this dialog and try again. Your account will be re-authenticated the next time you upload a file.

Michael Kogan (michael-kogan) wrote :

P.S.: Obviously I tried to close the dialog and give the uploading another go, but I always get the same message.

Timothy Zorn (systemdisc) wrote :

I'll fix it as soon as I can. This is when choosing Imgur Guest, not Imgur OAuth, correct?

Manuel Razzari (manael) wrote :

> I'm getting this error in a popup window when trying Imgur guest uploading:
>
> Invalid client_id: Maybe you or Imgur revoked or expired an access token.
> Please close this dialog and try again. Your account will be re-authenticated
> the next time you upload a file.

You just need to create an ~/.imgur-api-config file (see my comment on 01-13).

Or, since you will be distributing this, edit the hardcoded client_id and client_secret you'll find in shutter/resources/system/upload_plugins/upload/Imgur.pm

Michael Kogan (michael-kogan) wrote :

@Timothy Zorn: Exactly!

@Manuel Razzari: I hoped that for guest access this is not necessary, but if it is, I will set the id and secret fields, I guess...

Timothy Zorn (systemdisc) wrote :

I'll fix it in under 24 hours. I'm just busy today.

Michael Kogan (michael-kogan) wrote :

@Timothy Zorn: No worry, it won't run away. Thanks for taking care of it!

lp:~systemdisc/shutter/imgur-fix updated on 2017-01-28
1280. By Timothy Zorn on 2017-01-28

Fix Imgur Guest upload without config file

1281. By Timothy Zorn on 2017-01-28

Remove extra debug info which I was using

Timothy Zorn (systemdisc) wrote :

It should work out-of-the-box now.

Michael Kogan (michael-kogan) wrote :

Cool, works now, added the patch to Arch's Shutter package!

review: Approve
Phil (phd21) wrote :

Hi Everyone,

Could any of you please explain to me so I can explain to others, where I can download these updated file(s), and how to install them? Do I need to download just the "imgur.pm" file, or are there other files needed to get this working with "imgur", if so where? Are there new Shutter ".deb" packages available or a PPA for these updates?

FYI: I am using Linux Mint 17.3 KDE and Linux Mint 18.1 KDE and using the "shutter-testing-team" PPA to keep my Shutter application updated, is this the correct one? Have these changes been uploaded to the Shutter PPAs?

Also, since all of you seem good at this, have you come up with other ".pm" files for other image hosting services like "postimage.org", etc...? It would be really nice if Shutter had a configuration option to add other image hosts as well based upon the host's authentication method ...

Best regards to all of you,
Phil
phd21
<email address hidden>

Timothy Zorn (systemdisc) wrote :

You need bzr to download the branch.

sudo apt-get install bzr
bzr branch lp:~systemdisc/shutter/imgur-fix

> Hi Everyone,
>
> Could any of you please explain to me so I can explain to others, where I can
> download these updated file(s), and how to install them? Do I need to download
> just the "imgur.pm" file, or are there other files needed to get this working
> with "imgur", if so where? Are there new Shutter ".deb" packages available or
> a PPA for these updates?
>
> FYI: I am using Linux Mint 17.3 KDE and Linux Mint 18.1 KDE and using the
> "shutter-testing-team" PPA to keep my Shutter application updated, is this the
> correct one? Have these changes been uploaded to the Shutter PPAs?
>
>
> Also, since all of you seem good at this, have you come up with other ".pm"
> files for other image hosting services like "postimage.org", etc...? It would
> be really nice if Shutter had a configuration option to add other image hosts
> as well based upon the host's authentication method ...
>
> Best regards to all of you,
> Phil
> phd21
> <email address hidden>

Timothy Zorn (systemdisc) wrote :

Photon also apparently added this patch to Arch's Shutter package: https://aur.archlinux.org/packages/shutter/

It looks like there's a nice patch for my imgur fix there, too: https://aur.archlinux.org/cgit/aur.git/tree/fix-imgur.patch?h=shutter

Timothy Zorn (systemdisc) wrote :

For Debian, you may consider approaching the package maintainer with this merge request.
https://packages.qa.debian.org/s/shutter.html

Phil (phd21) wrote :

Hi Timothy Zorn,

Thank you for your replies.

I try to help out the members on the Linux Mint forums. Their main distributions are based on Ubuntu 14.04 (Linux Mint 17.x) and Ubuntu 16.04 (Linux Mint 18.x)

Although I am an experienced computer user, I am not familiar with using Launchpad, or Arch Linux for downloading and installing software and or their updates. I am learning them, and help from people like yourself makes that better (Thanks).

I want to be able to provide the Linux Mint members (including myself) a relatively easy way to update their Shutter application to use your version of the "imgur-fix" which includes the "Guest" and the "0Auth" authentication, that latter is more important. I used the BZR command you provided which downloaded and created your imgur-fix folder underneath my "/home/user69" folder, now what do I do to install it?

Using the Arch method looks like a lot of work, including installing the Arch package manager?. Is this safe to do in my Linux Mint (Ubuntu) system?

Best regards,
Phil
Linux Mint forum user=phd21
<email address hidden>

Michael Kogan (michael-kogan) wrote :

Hi Phil,

I think, you cannot install an AUR package in Mint. You can either install Shutter from source (not a good practice because there will be no easy way to remove it but possible), report the bug to the Debian people (Timothy Zorn posted a link to Debian's bug tracker above) wait till some Ubuntu dev incorporates the fix by Timothy Zorn into Ubuntu's Shutter package (there is already a pretty old bug report against Ubuntu's package: https://bugs.launchpad.net/shutter/+bug/1565048), report the bug to the Mint people and hope that they do this in the Mint package, find somebody who agrees to create a PPA for Shutter, switch to an Arch based distro and use my AUR package or not use the upload functionality. :)

Elvis de Freitas Souza (edigitalb) wrote :

I really want to know why this PR is not merged yet.

Michael Kogan (michael-kogan) wrote :

Because development is dead for years already, unfortunately. I think, this needs to be fixed on packaging level unless somebody likes to take over the development and at least merge all the patches which accumulated to far.

Timothy Zorn (systemdisc) wrote :

> Because development is dead for years already, unfortunately. I think, this
> needs to be fixed on packaging level unless somebody likes to take over the
> development and at least merge all the patches which accumulated to far.

How does one become the owner of lp:shutter? I wouldn't mind taking ownership and doing an initial cleanup just to keep the project alive - I could always assign other interested parties as contributors or however it works on LaunchPad/bzr.

Michael Kogan (michael-kogan) wrote :

Probably you need to get in touch with Mario (contact information in https://launchpad.net/~mario-kemper). If he is not reachable, maybe make a fork?

Adam Stokes (adam-stokes) wrote :

I think we should fork this project and get those merges in. Also create a team that could have several members who are willing to review code, get changes merged, and packages pushed out.

I'd like to participate and also would like to see what we can do about getting a confined snap built so that Fedora, Arch, Mint, and other Debian based distros can get these updates from a single distribution code base.

Michael Kogan (michael-kogan) wrote :

In principle I would like to participate as well since I was involved in translating and testing from the very beginning of Shutter's development (it was called GScrot back then) and have now taken over the packaging for Arch Linux. However, I don't know Perl and have very little programming experience, so I would be not much of a help, I guess. But maybe we should try to get some reply from Mario before making further plans.

Michael Kogan (michael-kogan) wrote :

P.S.: Just got a notification that Mario added me to the Shutter team and I added you guys!

review: Approve

Hi all,

sorry for being silent for some time, but unfortunately my time is very limited nowadays. I have added Michael Kogan to both relevant groups (Shutter Team and Shutter Testing Team) as Administrator. Please let me know if you are able to push/merge to lp:shutter (trunk) and please also let me know if you need any further information. Most of the things are working automatically (creating packages for PPAs via recipe et cetera).

Good luck and thanks for your contribution.

Bye
Mario

Michael Kogan (michael-kogan) wrote :

Thanks, Mario, I hope, we will manage!

Adam, Thimothy: I added you to both groups as well, but I won't have time to deal with the merging before Saturday, so feel free to go ahead!

Timothy Zorn (systemdisc) wrote :

I won't be available until this weekend, either.

Adam Stokes (adam-stokes) wrote :

I attempted to do the merge tonight but I don't seem to have access to push to trunk

Michael Kogan (michael-kogan) wrote :

Sorry for the delay, guys, I will look into it in the evening!

Michael Kogan (michael-kogan) wrote :

Looks like the permissions for the lp:shutter branch do not give push permissions to the Shutter group. I wrote a mail to Mario and asked for further instructions.

Timothy Zorn (systemdisc) wrote :

Do we have somewhere we can communicate in real-time, instead of communicating through the issue tracker? (IRC, Facebook, etc)

Maybe we should set up a channel in freenode or something.

Adam Stokes (adam-stokes) wrote :

Agreed, how about #shutter on freenode?

Timothy Zorn (systemdisc) wrote :

Sounds good to me

Michael Kogan (michael-kogan) wrote :

I joined you at the channel, guys!

Timothy Zorn (systemdisc) wrote :

Make sure to mention my nickname in IRC so I get a notification

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/shutter'
2--- bin/shutter 2014-12-23 23:02:02 +0000
3+++ bin/shutter 2017-01-28 09:57:21 +0000
4@@ -8353,7 +8353,10 @@
5 #~ print $name, $folder, $type, "\n";
6
7 if ( !exists $accounts{$name}
8- || !exists $accounts{$name}->{module} )
9+ || !exists $accounts{$name}->{module}
10+ || $accounts{$name}->{supports_anonymous_upload} ne &fct_upload_plugin_get_info( $ukey, 'supports_anonymous_upload' ) ||
11+ $accounts{$name}->{supports_authorized_upload} ne &fct_upload_plugin_get_info( $ukey, 'supports_authorized_upload' ) ||
12+ $accounts{$name}->{supports_oauth_upload} ne &fct_upload_plugin_get_info( $ukey, 'supports_oauth_upload' ) )
13 {
14
15 #show dialog and progress bar
16@@ -10632,7 +10635,7 @@
17 my $uploader = $hosting_module->new( $hosting_host, $sc->get_debug, $shutter_root, $d, $window, SHUTTER_VERSION );
18
19 #init module
20- if ( $uploader->init ) {
21+ if ( $uploader->init($hosting_username) ) {
22
23 my $counter = 1;
24 $hosting_progress->set_fraction(0);
25
26=== modified file 'share/shutter/resources/modules/Shutter/App/Common.pm'
27--- share/shutter/resources/modules/Shutter/App/Common.pm 2013-08-25 18:40:51 +0000
28+++ share/shutter/resources/modules/Shutter/App/Common.pm 2017-01-28 09:57:21 +0000
29@@ -48,7 +48,7 @@
30 my $self = { _shutter_root => shift, _mainwindow => shift, _appname => shift, _version => shift, _rev => shift, _pid => shift };
31
32 #vars
33- $self->{_debug_cparam} = FALSE;
34+ $self->{_debug_cparam} = TRUE;
35 $self->{_clear_cache} = FALSE;
36 $self->{_min_cparam} = FALSE;
37 $self->{_disable_systray_cparam} = FALSE;
38
39=== modified file 'share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm'
40--- share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm 2013-08-25 18:40:51 +0000
41+++ share/shutter/resources/modules/Shutter/App/SimpleDialogs.pm 2017-01-28 09:57:21 +0000
42@@ -59,6 +59,7 @@
43 my $detail_message = shift;
44 my $detail_checkbox = shift;
45 my $content_widget = shift;
46+ my $content_widget2 = shift;
47
48 my $info_dialog = Gtk2::MessageDialog->new( $self->{_window}, [qw/modal destroy-with-parent/], 'info', 'none', undef );
49
50@@ -71,6 +72,9 @@
51 if($content_widget){
52 $info_dialog->get_content_area()->add($content_widget);
53 }
54+ if($content_widget2){
55+ $info_dialog->get_content_area()->add($content_widget2);
56+ }
57
58 $info_dialog->add_button( $button_text_extra1, 10 ) if $button_text_extra1;
59 $info_dialog->add_button( $button_text_extra2, 20 ) if $button_text_extra2;
60
61=== modified file 'share/shutter/resources/system/upload_plugins/upload/Imgur.pm'
62--- share/shutter/resources/system/upload_plugins/upload/Imgur.pm 2013-08-25 18:40:51 +0000
63+++ share/shutter/resources/system/upload_plugins/upload/Imgur.pm 2017-01-28 09:57:21 +0000
64@@ -29,7 +29,8 @@
65 use strict;
66 use POSIX qw/setlocale/;
67 use Locale::gettext;
68-use Glib qw/TRUE FALSE/;
69+use Glib qw/TRUE FALSE/;
70+use MIME::Base64;
71
72 use Shutter::Upload::Shared;
73 our @ISA = qw(Shutter::Upload::Shared);
74@@ -38,12 +39,13 @@
75 $d->dir( $ENV{'SHUTTER_INTL'} );
76
77 my %upload_plugin_info = (
78- 'module' => "Imgur",
79+ 'module' => "Imgur",
80 'url' => "http://imgur.com/",
81 'registration' => "https://imgur.com/register",
82 'description' => $d->get( "Imgur is used to share photos with social networks and online communities, and has the funniest pictures from all over the Internet" ),
83- 'supports_anonymous_upload' => TRUE,
84+ 'supports_anonymous_upload' => TRUE,
85 'supports_authorized_upload' => FALSE,
86+ 'supports_oauth_upload' => TRUE,
87 );
88
89 binmode( STDOUT, ":utf8" );
90@@ -66,13 +68,128 @@
91
92 sub init {
93 my $self = shift;
94+ my $username = shift;
95
96- #do custom stuff here
97+ #do custom stuff here
98 use JSON;
99 use LWP::UserAgent;
100 use HTTP::Request::Common;
101-
102- return TRUE;
103+ use Path::Class;
104+
105+ $self->{_config} = { };
106+ $self->{_config_file} = file( $ENV{'HOME'}, '.imgur-api-config' );
107+
108+ $self->load_config;
109+ if ($username eq $d->get("OAuth"))
110+ {
111+ return $self->connect;
112+ }
113+
114+ return TRUE;
115+}
116+
117+sub load_config {
118+ my $self = shift;
119+
120+ if (-f $self->{_config_file}) {
121+ eval {
122+ $self->{_config} = decode_json($self->{_config_file}->slurp);
123+ };
124+ if ($@) {
125+ $self->{_config}->{client_id} = '9490811e0906b6e';
126+ $self->{_config}->{client_secret} = '158b57f13e9a51f064276bd9e31529fb065f741e';
127+ }
128+ }
129+ else {
130+ $self->{_config}->{client_id} = '9490811e0906b6e';
131+ $self->{_config}->{client_secret} = '158b57f13e9a51f064276bd9e31529fb065f741e';
132+ }
133+
134+ return TRUE;
135+}
136+
137+sub connect {
138+ my $self = shift;
139+ return $self->setup;
140+}
141+
142+sub setup {
143+ my $self = shift;
144+
145+ if ($self->{_debug_cparam}) {
146+ print "Setting up Imgur...\n";
147+ }
148+
149+ #some helpers
150+ my $sd = Shutter::App::SimpleDialogs->new;
151+
152+ #Authentication
153+ my $login_link = 'https://api.imgur.com/oauth2/authorize?response_type=pin&client_id=' . $self->{_config}->{client_id};
154+
155+ my $pin_entry = Gtk2::Entry->new();
156+ my $pin = '';
157+ $pin_entry->signal_connect(changed => sub {
158+ $pin = $pin_entry->get_text;
159+ });
160+
161+ my $response = $sd->dlg_info_message(
162+ $d->get("Please click on the button below to authorize with Imgur. Input the PIN you receive and press 'Apply' when you are done."),
163+ $d->get("Authorize with Imgur"),
164+ 'gtk-cancel','gtk-apply', undef,
165+ undef, undef, undef, undef, undef,
166+ Gtk2::LinkButton->new ($login_link, $d->get("Authorize")),
167+ $pin_entry,
168+ );
169+ if ($response == 20) {
170+
171+ if ($self->{_debug_cparam}) {
172+ print "Imgur: Authorizing...\n";
173+ }
174+
175+ my %params = (
176+ 'client_id' => $self->{_config}->{client_id},
177+ 'client_secret' => $self->{_config}->{client_secret},
178+ 'grant_type' => 'pin',
179+ 'pin' => $pin,
180+ );
181+
182+ my @params = (
183+ "https://api.imgur.com/oauth2/token",
184+ 'Content' => [%params]
185+ );
186+
187+ my $req = HTTP::Request::Common::POST(@params, 'Authorization' => 'Client-ID ' . $self->{_config}->{client_id});
188+
189+ my $client = LWP::UserAgent->new(
190+ 'timeout' => 20,
191+ 'keep_alive' => 10,
192+ 'env_proxy' => 1,
193+ );
194+ my $rsp = $client->request($req);
195+
196+ my $json = JSON->new();
197+ my $json_rsp = $json->decode($rsp->content);
198+
199+ if ($self->{_debug_cparam}) {
200+ print $pin . ' ' . $rsp->content;
201+ }
202+ if (exists $json_rsp->{status} && $json_rsp->{status} ne 200) {
203+ return $self->setup;
204+ }
205+
206+ $self->{_config}->{access_token} = $json_rsp->{access_token};
207+ $self->{_config}->{refresh_token} = $json_rsp->{refresh_token};
208+ $self->{_config}->{account_id} = $json_rsp->{account_id};
209+ $self->{_config}->{account_username} = $json_rsp->{account_username};
210+
211+ $self->{_config_file}->openw->print(encode_json($self->{_config}));
212+ chmod 0600, $self->{_config_file};
213+
214+ return TRUE;
215+ }
216+ else {
217+ return FALSE;
218+ }
219 }
220
221 sub upload {
222@@ -87,62 +204,66 @@
223 utf8::encode $password;
224 utf8::encode $username;
225
226- #~ if ( $username ne "" && $password ne "" ) {
227-
228- my $client = LWP::UserAgent->new(
229- 'timeout' => 20,
230- 'keep_alive' => 10,
231- 'env_proxy' => 1,
232- );
233-
234- eval{
235-
236- my $json = JSON->new();
237-
238- my %params = (
239- 'image' => [$upload_filename],
240- 'key' => '12ea5e932124142c5ef3c8d5a02557de',
241- );
242-
243- my @params = (
244- "http://api.imgur.com/1/upload.json",
245- 'Content_Type' => 'multipart/form-data',
246- 'Content' => [%params]
247- );
248-
249- my $req = HTTP::Request::Common::POST(@params);
250- my $rsp = $client->request($req);
251-
252- #~ print Dumper $json->decode( $rsp->content );
253-
254- $self->{_links} = $json->decode( $rsp->content );
255- $self->{_links} = $self->{_links}->{'rsp'};
256- if(defined $self->{_links}->{'stat'} && $self->{_links}->{'stat'} eq 'ok'){
257- $self->{_links} = $self->{_links}->{'image'};
258- #clean hash
259- foreach (keys %{$self->{_links}}){
260- if($_ eq 'delete_hash' || $_ eq 'image_hash'){
261- delete $self->{_links}->{$_};
262- next;
263- }
264- if( $self->{_debug_cparam}) {
265- print $_.": ".$self->{_links}->{$_}, "\n";
266- }
267- }
268- #set status (success)
269- $self->{_links}{'status'} = 200;
270- }else{
271- $self->{_links}{'status'} = $self->{_links}->{'image'}->{'error_msg'};
272+ my $client = LWP::UserAgent->new(
273+ 'timeout' => 20,
274+ 'keep_alive' => 10,
275+ 'env_proxy' => 1,
276+ );
277+
278+ eval {
279+
280+ my $json = JSON->new();
281+
282+ open( IMAGE, $upload_filename ) or die "$!";
283+ my $binary_data = do { local $/ = undef; <IMAGE>; };
284+ close IMAGE;
285+ my $encoded_image = encode_base64($binary_data);
286+
287+ my %params = (
288+ 'image' => $encoded_image,
289+ );
290+
291+ my @params = (
292+ "https://api.imgur.com/3/image",
293+ 'Content' => [%params]
294+ );
295+
296+ my $req;
297+ if ($username eq $d->get("OAuth") && $self->{_config}->{access_token}) {
298+ $req = HTTP::Request::Common::POST(@params, 'Authorization' => 'Bearer ' . $self->{_config}->{access_token});
299+ }
300+ else {
301+ $req = HTTP::Request::Common::POST(@params, 'Authorization' => 'Client-ID ' . $self->{_config}->{client_id});
302+ }
303+ my $rsp = $client->request($req);
304+
305+ #~ print Dumper $json->decode( $rsp->content );
306+
307+ my $json_rsp = $json->decode( $rsp->content );
308+
309+ if ($json_rsp->{'status'} ne 200) {
310+ unlink $self->{_config_file};
311+ $self->{_links}{'status'} = '';
312+ if (exists $json_rsp->{'data'}->{'error'}) {
313+ $self->{_links}{'status'} .= $json_rsp->{'data'}->{'error'} . ': ';
314 }
315-
316- };
317- if($@){
318- $self->{_links}{'status'} = $@;
319- #~ print "$@\n";
320+ $self->{_links}{'status'} .= $d->get("Maybe you or Imgur revoked or expired an access token. Please close this dialog and try again. Your account will be re-authenticated the next time you upload a file.");
321+ return %{ $self->{_links} };
322 }
323
324- #~ }
325-
326+ $self->{_links}{'status'} = $json_rsp->{'status'};
327+ $self->{_links}->{'direct_link'} = $json_rsp->{'data'}->{'link'};
328+ $self->{_links}->{'deletion_link'} = 'https://imgur.com/delete/' . $json_rsp->{'data'}->{'deletehash'};
329+ $self->{_links}->{'post_link'} = $json_rsp->{'data'}->{'link'};
330+ $self->{_links}->{'post_link'} =~ s/i\.imgur/imgur/;
331+ $self->{_links}->{'post_link'} =~ s/\.[^.]+$//;
332+
333+ };
334+ if ($@) {
335+ $self->{_links}{'status'} = $@;
336+ #~ print "$@\n";
337+ }
338+
339 #and return links
340 return %{ $self->{_links} };
341 }

Subscribers

People subscribed via source and target branches

to status/vote changes: