def send_update_sound(sound: Sound) -> None: # FIXME: not sure at all about that # Should not even work actor = sound.user.actor[0] if sound.path_artwork(): url_artwork = url_for("get_uploads_stuff", thing="artwork_sounds", stuff=sound.path_artwork(), _external=True) else: url_artwork = None # Fetch object and update fields object = sound.activity.payload["object"] object["name"] = sound.title object["content"] = sound.description # custom things that can change object["tags"] = [t.name for t in sound.tags] object["genre"] = sound.genre licence = sound.licence_info() licence["id"] = str(licence["id"]) # integers makes jsonld cry object["licence"] = licence object["artwork"] = url_artwork to = [follower.actor.url for follower in actor.followers] to.append(ap.AS_PUBLIC) raw_update = dict(to=to, actor=actor.to_dict(), object=object) raw_update["@context"] = DEFAULT_CTX current_app.logger.debug(f"recipients: {raw_update['to']}") update = ap.Update(**raw_update) post_to_outbox(update)
def send_update_profile(user: User) -> None: # FIXME: not sure at all about that actor = user.actor[0] raw_update = dict(to=[follower.actor.url for follower in actor.followers], actor=actor.to_dict(), object=actor.to_dict()) current_app.logger.debug(f"recipients: {raw_update['to']}") update = ap.Update(**raw_update) post_to_outbox(update)
def admin_update_actor() -> _Response: update = ap.Update( actor=MY_PERSON.id, object=MY_PERSON.to_dict(), to=[MY_PERSON.followers], cc=[ap.AS_PUBLIC], published=now(), ) post_to_outbox(update) return "OK"
def admin_update_actor() -> _Response: # FIXME(tsileo): make this a task, and keep track of our own actor_hash at startup update = ap.Update( actor=MY_PERSON.id, object=MY_PERSON.to_dict(), to=[MY_PERSON.followers], cc=[ap.AS_PUBLIC], published=now(), ) post_to_outbox(update) return "OK"
def send_update_sound(sound: Sound) -> None: # FIXME: not sure at all about that # Should not even work actor = sound.user.actor[0] # Fetch object and update fields object = sound.activity.payload["object"] object["name"] = sound.title object["content"] = sound.description raw_update = dict(to=[follower.actor.url for follower in actor.followers], actor=actor.to_dict(), object=object) current_app.logger.debug(f"recipients: {raw_update['to']}") update = ap.Update(**raw_update) post_to_outbox(update)
def task_send_actor_update() -> _Response: task = p.parse(flask.request) app.logger.info(f"task={task!r}") try: update = ap.Update( actor=MY_PERSON.id, object=MY_PERSON.to_dict(), to=[MY_PERSON.followers], cc=[ap.AS_PUBLIC], published=now(), context=new_context(), ) post_to_outbox(update) except Exception as err: app.logger.exception(f"failed to send actor update") raise TaskError() from err return ""
def task_update_question() -> _Response: """Sends an Update.""" task = p.parse(flask.request) app.logger.info(f"task={task!r}") iri = task.payload try: app.logger.info(f"Updating question {iri}") cc = [config.ID + "/followers"] doc = DB.activities.find_one({ "box": Box.OUTBOX.value, "remote_id": iri }) _add_answers_to_question(doc) question = ap.Question(**doc["activity"]["object"]) raw_update = dict( actor=question.id, object=question.to_dict(embed=True), attributedTo=MY_PERSON.id, cc=list(set(cc)), to=[ap.AS_PUBLIC], ) raw_update["@context"] = config.DEFAULT_CTX update = ap.Update(**raw_update) print(update) print(update.to_dict()) post_to_outbox(update) except HTTPError as err: app.logger.exception("request failed") if 400 >= err.response.status_code >= 499: app.logger.info("client error, no retry") return "" raise TaskError() from err except Exception as err: app.logger.exception("task failed") raise TaskError() from err return ""