Example #1
0
 def get_stream_object(self, request, username, *args, **kwargs):
     user = bridge.get_user_by_username(request, username)
     if not user:
         raise Http404()
     self.view_ctx['owner'] = user
     if request.user.is_authenticated() and request.user.adn_user.id != user.id:
         self.post_create_pre_text = u'@%s' % (username)
     self.view_ctx['rss_link'] = 'https://api.app.net/feed/rss/users/%d/posts' % (user.id)
     return user
Example #2
0
 def get_stream_object(self, request, username, *args, **kwargs):
     user = bridge.get_user_by_username(request, username)
     if not user:
         raise Http404()
     self.view_ctx['owner'] = user
     if request.user.is_authenticated(
     ) and request.user.adn_user.id != user.id:
         self.post_create_pre_text = u'@%s' % (username)
     self.view_ctx[
         'rss_link'] = 'https://api.app.net/feed/rss/users/%d/posts' % (
             user.id)
     return user
Example #3
0
def well_known_webfinger(request):
    resource = request.GET.get('resource')
    if not resource:
        raise Http404()

    fake_email = resource.lower().replace('acct:', '')
    username, domain = fake_email.split('@', 1)

    current_domain = 'alpha.%s' % (settings.PARENT_HOST)
    if domain != current_domain:
        raise Http404()

    user = bridge.get_user_by_username(request, username)

    if not user:
        raise Http404()

    def link(rel, href, _type=None):
        link = dict(rel=rel, href=href)
        if _type:
            link['type'] = _type

        return link

    user_profile = smart_reverse(request,
                                 'user_detail_view',
                                 args=[username],
                                 force_qualified=True)
    activitystream = 'https://api.%s/users/@%s/activitystream' % (
        settings.PARENT_HOST, username)
    resp = json.dumps({
        "subject":
        'acct:%s@%s' % (username, current_domain),
        "aliases": [
            user_profile,
        ],
        "links": [
            link(rel='http://webfinger.net/rel/profile-page',
                 href=user_profile,
                 _type='text/html'),
            link(rel='http://activitystrea.ms/specs/json/1.0/',
                 href=activitystream)
        ]
    })

    return HttpResponse(resp, content_type='application/json')
Example #4
0
def well_known_webfinger(request):
    resource = request.GET.get('resource')
    if not resource:
        raise Http404()

    fake_email = resource.lower().replace('acct:', '')
    username, domain = fake_email.split('@', 1)

    current_domain = 'alpha.%s' % (settings.PARENT_HOST)
    if domain != current_domain:
        raise Http404()

    user = bridge.get_user_by_username(request, username)

    if not user:
        raise Http404()

    def link(rel, href, _type=None):
        link = dict(rel=rel, href=href)
        if _type:
            link['type'] = _type

        return link

    user_profile = smart_reverse(request, 'user_detail_view', args=[username], force_qualified=True)
    activitystream = 'https://api.%s/users/@%s/activitystream' % (settings.PARENT_HOST, username)
    resp = json.dumps({
        "subject": 'acct:%s@%s' % (username, current_domain),
        "aliases": [
            user_profile,
        ],
        "links": [
            link(rel='http://webfinger.net/rel/profile-page', href=user_profile, _type='text/html'),
            link(rel='http://activitystrea.ms/specs/json/1.0/', href=activitystream)
        ]
    })

    return HttpResponse(resp, content_type='application/json')
Example #5
0
 def get_stream_object(self, request, *args, **kwargs):
     owner_username = kwargs.get('username', '')
     owner = bridge.get_user_by_username(request, owner_username)
     self.view_ctx['owner'] = owner
     return owner
Example #6
0
 def get_stream_object(self, request, *args, **kwargs):
     owner_username = kwargs.get('username', '')
     owner = bridge.get_user_by_username(request, owner_username)
     self.view_ctx['owner'] = owner
     return owner