API Not using URL shortener set in user profile

API Not using URL shortener set in user profile

Issue ID:3017
Issue Category:bug
Component:api
Priority:normal
Status:active
Assigned:mymmn
Version:1.0
Milestone:1.0
Keywords:patch exists

I'm using my own url shortenrt script Yourl which has a plugin for StatusNet. I've installed it and added the following to config.php

addPlugin('Yourls', array('shortenerName'=>'YOURLS','freeService'=>false,'serviceUrl'=>'http://xxx.yyy/yourls-api.php?signature=8ff64807a1&action=shorturl&url=%1$s&format=json'));

It works fine if you goto Account->Others->Shorten With->YOURL you type in a post longer than 140 chars with a url and it shortens it as it should. The problem comes when I want to access the API from a DOS window on Windows XP.

If I issue this command

c:\$\curl\curl.exe -u user:passwor -d status="This is coing to be quite a long message so that it to shorten the url a big biy lol I hope it does it OK http://www.avery.verylongurl.tomakesure.itbreaksthe140 chars.com" http://xxx.yyy.info/api/statuses/update.xml

It shortens the URL but does it with the default url.ca not YOURL which is set for that user!

I've tried adding this to config.php

unset($config['plugins']['default']['LilUrl']);
unset($config['plugins']['default']['SimpleUrl']);
unset($config['plugins']['default']['2tu.us']);
unset($config['plugins']['default']['PtitUrl']);
unset($config['plugins']['default']['TightUrl']);

Which leaves only YOURLS as an option in other settings but when the status command is run from DOS it returns an error saying the line is more than 140 chars!

Updates

#1

This should be working in the upcoming 0.9.7; there've been some internal fixes for shortening user settings.

Can you test pulling 0.9.x branch out of our git repository? http://www.gitorious.org/statusnet

#2

I would if I could find it! created an account and gave up at the SSH key part.
If you could point me at a zip I'd be happy to test it.

Carol

#3

They do kinda hide the branch download links in that system don't they. :)

This should do to grab a direct download without having to go through the source-control app directly:
http://www.gitorious.org/statusnet/mainline/archive-tarball/0.9.x

#4

lol I'd have never fund it. I'm away from home tomorrow so I'll test it sat / sun and let you know how it went.

Regards,

Carol

#5

Using build StatusNet 0.9.7alpha1 the results are exacly the same. It still doesn't work. The API still uses url.ca not the one set as default. Even with All others disabled it reports line is longer than 140 chars :(

#6

Still seems to be working for me on 0.9.x and testing branches (0.9.7 alpha); I'm adding bit.ly:

addPlugin('BitlyUrl');

then setting my username & API key for bit.ly in the admin panels, then selecting bitly as my account's preferred shortener.

Posts both from the web and from the API (via StatusNet Desktop client in my case) then get their long URLs shortened with bit.ly. Selecting is.gd in my account settings also works; from both sources the URL gets shortened with is.gd.

#7

Does this problem still occur?

#8

Yes, this problem still occurs. I encounter this with the latest identi.ca.

#9

Milestone:0.6» 1.0
Version:0.9» 1.0

I'd like to add my voice as well. This problem occurs with current identi.ca (running SN version 1.0.0 ATM). Any URL via XML API seems to be shortened even though that has been disabled in the user profile. This happens even if the message was < 140 chars.

#10

Still seeing this in 1.0;
updates via web obeys settings, updates via API ignores URL shortener service and the length settings to trigger shortening.
Compare http://identi.ca/notice/84372013 & http://identi.ca/notice/84410497

#11

Bug is still present in identi.ca, version 1.1.0-release. What is the status of this bug?

@skyfaller has asked about the issue on #statusnet, and to me it seems like the bug is still there.

#12

Assigned to:Anonymous» mymmn
Keywords:+patch exists

I just checked the code and it seems this is caused by overwriting the user object with (supposedly) nothing in the function common_shorten_links in lib/util.php

function common_shorten_links($text, $always = false, User $user=null)
{
$user = common_current_user();

The first thing the function does is overwrite whatever value you may have sent in the $user parameter. The api calls etc. are doing it all right (common_shorten_links does get the correct User object from what I can see) and thus this should be the only change required.

I've made a merge request for this, https://gitorious.org/statusnet/mainline/merge_requests/207

Login or Register to modify this issue, or to receive updates by email.

You can also subscribe to the RSS feed for updates to this issue.