require a request to shorten the url

This commit is contained in:
mixedpuppy 2010-10-15 13:55:52 -07:00
Родитель ae33f14f45
Коммит 930850faa6
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -6,6 +6,7 @@ import sys
import httplib2
import copy
from urlparse import urlparse
from paste.deploy.converters import asbool
from pylons import config, request, response, session
from pylons.controllers.util import abort, redirect
@ -45,6 +46,7 @@ The 'send' namespace is used to send updates to our supported services.
message = request.POST.get('message', '')
username = request.POST.get('username')
longurl = request.POST.get('link')
shorten = asbool(request.POST.get('shorten', 0))
shorturl = request.POST.get('shorturl')
userid = request.POST.get('userid')
to = request.POST.get('to')
@ -79,7 +81,7 @@ The 'send' namespace is used to send updates to our supported services.
return {'result': result, 'error': error}
args = copy.copy(request.POST)
if not shorturl and longurl:
if shorten and not shorturl and longurl:
u = urlparse(longurl)
if not u.scheme:
longurl = 'http://' + longurl