Beispiel #1
0
def update_remote_actor(actor_id: int,
                        activity_actor: ap.BaseActivity) -> None:
    """
    :param actor_id: an Actor db ID
    :param activity_actor: a Little Boxes Actor object
    :return: nothing
    """
    actor = Actor.query.filter(Actor.id == actor_id).first()
    current_app.logger.debug(
        f"asked to update Actor {actor_id}: {activity_actor!r}")

    actor.preferred_username = activity_actor.preferredUsername
    domain = urlparse(activity_actor.url)
    actor.domain = domain.netloc
    actor.name = activity_actor.name
    actor.manually_approves_followers = False
    actor.url = activity_actor.id  # FIXME: or .id ??? [cf backend.py:52-53]
    actor.shared_inbox_url = activity_actor._data.get("endpoints",
                                                      {}).get("sharedInbox")
    actor.inbox_url = activity_actor.inbox
    actor.outbox_url = activity_actor.outbox
    actor.public_key = activity_actor.get_key().pubkey_pem
    actor.summary = activity_actor.summary
    actor.followers_url = activity_actor.followers
    actor.following_url = activity_actor.following

    db.session.commit()
Beispiel #2
0
def create_remote_actor(activity_actor: ap.BaseActivity):
    """
    :param activity_actor: a Little Boxes Actor object
    :return: an Actor object
    """
    actor = Actor()
    actor.preferred_username = activity_actor.preferredUsername
    domain = urlparse(activity_actor.url)
    actor.domain = domain.netloc
    actor.type = "Person"
    actor.name = activity_actor.name
    actor.manually_approves_followers = False
    actor.url = activity_actor.id  # FIXME: or .id ??? [cf backend.py:52-53]
    actor.shared_inbox_url = activity_actor._data.get("endpoints", {}).get("sharedInbox")
    actor.inbox_url = activity_actor.inbox
    actor.outbox_url = activity_actor.outbox
    actor.public_key = activity_actor.get_key().pubkey_pem
    actor.summary = activity_actor.summary
    actor.followers_url = activity_actor.followers
    actor.following_url = activity_actor.following

    user = User()
    user.email = None
    user.name = activity_actor.preferredUsername
    user.password = None
    user.active = False
    user.confirmed_at = None
    user.display_name = activity_actor.name
    user.local = False

    actor.user = user

    # TODO: Avatar

    return actor, user
Beispiel #3
0
def create_remote_actor(activity_actor: ap.BaseActivity):
    """
    :param activity_actor: a Little Boxes Actor object
    :return: an Actor object
    """
    actor = Actor()
    print(activity_actor)
    actor.preferred_username = activity_actor.preferredUsername
    domain = urlparse(activity_actor.url)
    actor.domain = domain.netloc
    actor.type = "Person"
    # FIXME: test for .name, it won't exist if not set (at least for mastodon)
    actor.name = activity_actor.preferredUsername  # mastodon don't have .name
    actor.manually_approves_followers = False
    actor.url = activity_actor.id  # FIXME: or .id ??? [cf backend.py:52-53]
    actor.shared_inbox_url = activity_actor._data.get("endpoints",
                                                      {}).get("sharedInbox")
    actor.inbox_url = activity_actor.inbox
    actor.outbox_url = activity_actor.outbox
    actor.public_key = activity_actor.get_key().pubkey_pem
    actor.summary = activity_actor.summary
    actor.followers_url = activity_actor.followers
    actor.following_url = activity_actor.following

    return actor
Beispiel #4
0
def create_remote_actor(activity_actor: ap.BaseActivity):
    """
    :param activity_actor: a Little Boxes Actor object
    :return: an Actor object
    """
    actor = Actor()
    actor.preferred_username = activity_actor.preferredUsername
    # TODO this should be handled better, like with pyld...
    # handle funkwhale Actor types
    url = activity_actor.url
    if isinstance(url, list):
        url = next(
            iter(item for item in url if item["type"] == "Link"
                 and item["mediaType"] == "text/html"), None)["href"]
    domain = urlparse(url)
    actor.domain = domain.netloc
    actor.type = "Person"
    actor.name = activity_actor.name
    actor.manually_approves_followers = False
    actor.url = activity_actor.id  # FIXME: or .id ??? [cf backend.py:52-53]
    actor.shared_inbox_url = activity_actor._data.get("endpoints",
                                                      {}).get("sharedInbox")
    actor.inbox_url = activity_actor.inbox
    actor.outbox_url = activity_actor.outbox
    actor.public_key = activity_actor.get_key().pubkey_pem
    actor.summary = activity_actor.summary
    actor.followers_url = activity_actor.followers
    actor.following_url = activity_actor.following

    user = User()
    user.email = None
    user.name = activity_actor.preferredUsername
    user.password = None
    user.active = False
    user.confirmed_at = None
    user.display_name = activity_actor.name
    user.local = False

    actor.user = user

    # TODO: Avatar

    return actor, user