def expand_uri(request, uri):
    doc = None
    if _postgres_enabled(request):
        doc = models.Document.find_by_uris(request.db, [uri]).one_or_none()
    else:
        doc = models.elastic.Document.get_by_uri(uri)

    if doc is None:
        return [uri]

    # We check if the match was a "canonical" link. If so, all annotations
    # created on that page are guaranteed to have that as their target.source
    # field, so we don't need to expand to other URIs and risk false positives.
    docuris = doc.document_uris
    for docuri in docuris:
        if docuri.uri == uri and docuri.type == 'rel-canonical':
            return [uri]

    return [docuri.uri for docuri in docuris]
Retrieve data stored with set_session_data
dataset/ETHPy150Open hypothesis/h/h/api/storage.py/expand_uri--crossover with--dataset/ETHPy150Open matrix-org/synapse/synapse/handlers/auth.py/AuthHandler.get_session_data