Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gigadoc 2
diaspora
Commits
5bcc3acb
Commit
5bcc3acb
authored
Feb 26, 2011
by
MrZYX
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save the correct url on redirect in http_multi job; be tolerant about messed up urls in the db
parent
a9ab8422
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
25 deletions
+47
-25
app/models/jobs/http_multi.rb
app/models/jobs/http_multi.rb
+11
-1
app/models/person.rb
app/models/person.rb
+15
-2
config/locale_settings.yml
config/locale_settings.yml
+8
-19
spec/models/jobs/http_multi_spec.rb
spec/models/jobs/http_multi_spec.rb
+1
-1
spec/models/person_spec.rb
spec/models/person_spec.rb
+12
-2
No files found.
app/models/jobs/http_multi.rb
View file @
5bcc3acb
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require
'uri'
module
Job
class
HttpMulti
<
Base
@queue
=
:http
...
...
@@ -24,7 +30,11 @@ module Job
request
.
on_complete
do
|
response
|
if
response
.
code
>=
300
&&
response
.
code
<
400
if
response
.
headers_hash
[
'Location'
]
==
response
.
request
.
url
.
sub
(
'http://'
,
'https://'
)
person
.
url
=
response
.
headers_hash
[
'Location'
]
location
=
URI
.
parse
(
response
.
headers_hash
[
'Location'
])
newuri
=
"
#{
location
.
scheme
}
://
#{
location
.
host
}
"
newuri
+=
":
#{
location
.
port
}
"
unless
[
"80"
,
"443"
].
include?
(
location
.
port
.
to_s
)
newuri
+=
"/"
person
.
url
=
newuri
person
.
save
end
end
...
...
app/models/person.rb
View file @
5bcc3acb
...
...
@@ -2,6 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require
'uri'
require
File
.
join
(
Rails
.
root
,
'lib/hcard'
)
class
Person
<
ActiveRecord
::
Base
...
...
@@ -93,13 +94,25 @@ class Person < ActiveRecord::Base
def
owns?
(
post
)
self
==
post
.
person
end
def
url
begin
uri
=
URI
.
parse
(
@attributes
[
'url'
])
url
=
"
#{
uri
.
scheme
}
://
#{
uri
.
host
}
"
url
+=
":
#{
uri
.
port
}
"
unless
[
"80"
,
"443"
].
include?
(
uri
.
port
.
to_s
)
url
+=
"/"
rescue
Exception
=>
e
url
=
@attributes
[
'url'
]
end
url
end
def
receive_url
"
#{
self
.
url
}
receive/users/
#{
self
.
guid
}
/"
"
#{
url
}
receive/users/
#{
self
.
guid
}
/"
end
def
public_url
"
#{
self
.
url
}
public/
#{
self
.
owner
.
username
}
"
"
#{
url
}
public/
#{
self
.
owner
.
username
}
"
end
def
public_key_hash
...
...
config/locale_settings.yml
View file @
5bcc3acb
...
...
@@ -34,22 +34,11 @@ available:
tr
:
'
Türk'
zh
:
'
中文'
fallbacks
:
en-GB
:
-
:en
en-US
:
-
:en
en_shaw
:
-
:en
-
:en-GB
-
:en-US
sv
:
-
:sv-SE
he
:
-
:he-IL
es-CL
:
-
:es
gl
:
-
:gl-ES
zh
:
-
:zh-CN
-
:zh-TW
en-GB
:
[:
en
]
en-US
:
[:
en
]
en_shaw
:
[:
en
,
:
en-GB
,
:
en-US
]
sv
:
[:
sv-SE
]
he
:
[:
he-IL
]
es-CL
:
[:
es
]
gl
:
[:
gl-ES
]
zh
:
[:
zh-CN
,
:
zh-TW
]
spec/models/jobs/http_multi_spec.rb
View file @
5bcc3acb
...
...
@@ -72,6 +72,6 @@ describe Job::HttpMulti do
Job
::
HttpMulti
.
perform
(
bob
.
id
,
@post_xml
,
[
person
.
id
])
person
.
reload
person
.
url
.
should
=
~
/https:\/\/remote.net\//
person
.
url
.
should
=
=
"https://remote.net/"
end
end
spec/models/person_spec.rb
View file @
5bcc3acb
...
...
@@ -20,11 +20,21 @@ describe Person do
end
describe
"vaild url"
do
it
'should allow for https urls'
do
it
'should allow for https urls'
do
person
=
Factory
.
create
(
:person
,
:url
=>
"https://example.com"
)
person
.
should
be_valid
end
end
it
'should always return the correct receive url'
do
person
=
Factory
.
create
(
:person
,
:url
=>
"https://example.com/a/bit/messed/up"
)
person
.
receive_url
.
should
==
"https://example.com/receive/users/
#{
person
.
guid
}
/"
end
it
'should allow ports in the url'
do
person
=
Factory
.
create
(
:person
,
:url
=>
"https://example.com:3000/"
)
person
.
url
.
should
==
"https://example.com:3000/"
end
end
describe
'#diaspora_handle'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment