kopia lustrzana https://gitlab.com/jaywink/federation
Allow guid to be empty when parsing or generating diaspora ID
Sometimes we just want a URI format Diaspora ID but don't have a guid.merge-requests/130/head
rodzic
511ef6676c
commit
0170a12a95
|
@ -44,6 +44,7 @@ def test_get_fetch_content_endpoint():
|
|||
|
||||
def test_parse_diaspora_uri():
|
||||
assert parse_diaspora_uri("diaspora://user@example.com/spam/eggs") == ("user@example.com", "spam", "eggs")
|
||||
assert parse_diaspora_uri("diaspora://user@example.com/spam/") == ("user@example.com", "spam", "")
|
||||
assert parse_diaspora_uri("diaspora://user@example.com/spam/eggs@spam") == ("user@example.com", "spam", "eggs@spam")
|
||||
assert not parse_diaspora_uri("https://user@example.com/spam/eggs")
|
||||
assert not parse_diaspora_uri("spam and eggs")
|
||||
|
@ -57,6 +58,7 @@ def test_parse_profile_diaspora_id():
|
|||
|
||||
def test_generate_diaspora_profile_id():
|
||||
assert generate_diaspora_profile_id("foobar@example.com", "1234") == "diaspora://foobar@example.com/profile/1234"
|
||||
assert generate_diaspora_profile_id("foobar@example.com") == "diaspora://foobar@example.com/profile/"
|
||||
|
||||
|
||||
class TestRetrieveDiasporaHCard:
|
||||
|
|
|
@ -163,11 +163,14 @@ def parse_profile_diaspora_id(id):
|
|||
return handle, guid
|
||||
|
||||
|
||||
def generate_diaspora_profile_id(handle, guid):
|
||||
def generate_diaspora_profile_id(handle, guid=None):
|
||||
"""
|
||||
Generate a Diaspora profile ID from handle and guid.
|
||||
|
||||
Sometimes we don't know the guid if we just have a handle, but still we want to store it
|
||||
in URI format.
|
||||
"""
|
||||
return "diaspora://%s/profile/%s" % (handle, guid)
|
||||
return "diaspora://%s/profile/%s" % (handle, guid or "")
|
||||
|
||||
|
||||
def parse_profile_from_hcard(hcard, handle):
|
||||
|
|
Ładowanie…
Reference in New Issue