def make_federable_profile(profile: Profile) -> Optional[base.Profile]: """Make a federable profile.""" logger.info("make_federable_profile - Profile: %s", profile) try: return base.Profile( raw_content="", public= True, # A profile is public in the context of federation if it is sent outwards name=profile.name_or_handle, image_urls={ "small": profile.safer_image_url_small, "medium": profile.safer_image_url_medium, "large": profile.safer_image_url_large, }, public_key=profile.rsa_public_key, url=profile.url, created_at=profile.created, base_url=settings.SOCIALHOME_URL, id=profile.fid, handle=profile.handle or "", guid=str(profile.uuid) if profile.is_local else profile.guid if profile.guid else "", inboxes={ "private": profile.inbox_private, "public": profile.inbox_public, }, username=profile.username_part, ) except Exception as ex: logger.exception("_make_profile - Failed to convert %s: %s", profile.uuid, ex) return
def make_federable_profile(profile): """Make a federable profile.""" logger.info("make_federable_profile - Profile: %s", profile) try: return base.Profile( raw_content="", public=True if profile.visibility == Visibility.PUBLIC else False, name=profile.name, image_urls={ "small": profile.safer_image_url_small, "medium": profile.safer_image_url_medium, "large": profile.safer_image_url_large, }, public_key=profile.rsa_public_key, url=profile.local_url, created_at=profile.created, base_url=settings.SOCIALHOME_URL, id=profile.fid, handle=profile.handle or "", guid=str(profile.uuid), ) except Exception as ex: logger.exception("_make_profile - Failed to convert %s: %s", profile.uuid, ex) return None
def test_search_by_handle_fetches_unknown_profile(self, mock_retrieve): fid = "*****@*****.**" mock_retrieve.return_value = base.Profile( name="I don't exist locally", id=fid, handle=fid, public=True, ) self.get("%s?q=%s" % (reverse("search:global"), fid), follow=True) profile = Profile.objects.fed(fid).get() self.assertResponseNotContains("Profiles", html=False) self.assertEqual(self.context["view"].__class__, ProfileAllContentView) self.assertEqual(self.context["object"], profile) # Survives extra spaces around self.get("%s?q=%s" % (reverse("search:global"), "%[email protected]%20"), follow=True) self.assertResponseNotContains("Profiles", html=False) self.assertEqual(self.context["view"].__class__, ProfileAllContentView) self.assertEqual(self.context["object"], profile)
def make_federable_profile(profile): """Make a federable profile.""" logger.info("make_federable_profile - Profile: %s", profile) try: return base.Profile( handle=profile.handle, raw_content="", public=True if profile.visibility == Visibility.PUBLIC else False, guid=profile.guid, name=profile.name, image_urls={ "small": profile.safer_image_url_small, "medium": profile.safer_image_url_medium, "large": profile.safer_image_url_large, }, public_key=profile.rsa_public_key, ) except Exception as ex: logger.exception("_make_profile - Failed to convert %s: %s", profile.guid, ex) return None