예제 #1
0
 def setUpTestData(cls):
     super(TestProcessEntities, cls).setUpTestData()
     cls.profile = Mock()
     cls.post = entities.PostFactory()
     cls.retraction = base.Retraction(handle=cls.post.handle,
                                      target_guid=cls.post.guid,
                                      entity_type="Post")
예제 #2
0
def make_federable_retraction(obj: Union[Content, Profile],
                              author: Optional[Profile] = None):
    """Make object retraction federable by converting it to a federation entity."""
    logger.info("make_federable_retraction - Object: %s", obj)
    try:
        if isinstance(obj, Content):
            entity_type = {
                ContentType.REPLY: "Comment",
                ContentType.SHARE: "Share",
                ContentType.CONTENT: "Post",
            }.get(obj.content_type)
            actor_id = author.fid
            handle = author.handle
        elif isinstance(obj, Profile):
            entity_type = "Profile"
            actor_id = obj.fid
            handle = obj.handle
        else:
            logger.warning(
                "make_federable_retraction - Unknown object type %s", obj)
            return
        return base.Retraction(
            entity_type=entity_type,
            actor_id=actor_id,
            target_id=obj.fid,
            handle=handle,
            target_guid=obj.guid,
        )
    except Exception as ex:
        logger.exception(
            "make_federable_retraction - Failed to convert %s: %s", obj.fid,
            ex)
예제 #3
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.post = entities.PostFactory()
     cls.comment = base.Comment()
     cls.retraction = base.Retraction()
     cls.relationship = base.Relationship()
     cls.follow = base.Follow()
예제 #4
0
 def test_removes_follower(self):
     self.remote_profile.following.add(self.profile)
     process_entity_retraction(
         base.Retraction(entity_type="Profile", _receiving_guid=self.profile.guid),
         self.remote_profile,
     )
     self.assertEqual(self.remote_profile.following.count(), 0)
예제 #5
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.post = entities.PostFactory()
     cls.comment = base.Comment()
     cls.retraction = base.Retraction()
     cls.follow = base.Follow()
     cls.profile = BaseProfileFactory()
     cls.share = BaseShareFactory()
     cls.receiving_user = UserFactory()
     cls.receiving_profile = cls.receiving_user.profile
예제 #6
0
def make_federable_retraction(content, author):
    """Make Content retraction federable by converting it to a federation entity."""
    logging.info("make_federable_retraction - Content: %s" % content)
    try:
        return base.Retraction(
            entity_type="Comment" if content.parent else "Post",
            handle=author.handle,
            target_guid=content.guid,
        )
    except Exception as ex:
        logger.exception(
            "make_federable_retraction - Failed to convert %s: %s",
            content.guid, ex)
        return None
예제 #7
0
파일: tasks.py 프로젝트: qincpp/socialhome
def make_federable_retraction(content, author):
    """Make Content retraction federable by converting it to a federation entity."""
    logging.info("make_federable_retraction - Content: %s" % content)
    try:
        return base.Retraction(
            entity_type=
            "Post",  # Well, currently, at some point this could be something else
            handle=author.handle,
            target_guid=content.guid,
        )
    except Exception as ex:
        logger.exception(
            "make_federable_retraction - Failed to convert %s: %s",
            content.guid, ex)
        return None
예제 #8
0
def make_federable_retraction(content, author):
    """Make Content retraction federable by converting it to a federation entity."""
    logger.info("make_federable_retraction - Content: %s", content)
    try:
        entity_type = "Comment" if content.content_type == ContentType.REPLY else \
            "Share" if content.content_type == ContentType.SHARE else "Post"
        return base.Retraction(
            # TODO check share federation
            entity_type=entity_type,
            handle=author.handle,
            target_guid=content.guid,
        )
    except Exception as ex:
        logger.exception(
            "make_federable_retraction - Failed to convert %s: %s",
            content.guid, ex)
        return None