Custom emojis support
This commit is contained in:
@@ -37,6 +37,7 @@ from core.shared import noindex
|
||||
from core.shared import p
|
||||
from core.shared import paginated_query
|
||||
from utils import now
|
||||
from utils.emojis import EMOJIS_BY_NAME
|
||||
from utils.lookup import lookup
|
||||
|
||||
blueprint = flask.Blueprint("admin", __name__)
|
||||
@@ -252,6 +253,7 @@ def admin_new() -> _Response:
|
||||
thread=thread,
|
||||
visibility=ap.Visibility,
|
||||
emojis=config.EMOJIS.split(" "),
|
||||
custom_emojis=EMOJIS_BY_NAME,
|
||||
)
|
||||
|
||||
|
||||
|
@@ -43,6 +43,7 @@ from core.shared import _Response
|
||||
from core.shared import csrf
|
||||
from core.shared import login_required
|
||||
from core.tasks import Tasks
|
||||
from utils import emojis
|
||||
from utils import now
|
||||
|
||||
blueprint = flask.Blueprint("api", __name__)
|
||||
@@ -398,6 +399,9 @@ def api_new_note() -> _Response:
|
||||
|
||||
content, tags = parse_markdown(source)
|
||||
|
||||
# Check for custom emojis
|
||||
tags = tags + emojis.tags(content)
|
||||
|
||||
to: List[str] = []
|
||||
cc: List[str] = []
|
||||
|
||||
@@ -467,6 +471,8 @@ def api_new_question() -> _Response:
|
||||
raise ValueError("missing content")
|
||||
|
||||
content, tags = parse_markdown(source)
|
||||
tags = tags + emojis.tags(content)
|
||||
|
||||
cc = [ID + "/followers"]
|
||||
|
||||
for tag in tags:
|
||||
|
@@ -147,6 +147,7 @@ def task_cache_object() -> _Response:
|
||||
activity = ap.fetch_remote_activity(iri)
|
||||
app.logger.info(f"activity={activity!r}")
|
||||
obj = activity.get_object()
|
||||
Tasks.cache_emojis(obj)
|
||||
|
||||
# Refetch the object actor (without cache)
|
||||
obj_actor = ap.fetch_remote_activity(obj.get_actor().id, no_cache=True)
|
||||
@@ -367,6 +368,22 @@ def task_cache_actor_icon() -> _Response:
|
||||
return ""
|
||||
|
||||
|
||||
@blueprint.route("/task/cache_emoji", methods=["POST"])
|
||||
def task_cache_emoji() -> _Response:
|
||||
task = p.parse(flask.request)
|
||||
app.logger.info(f"task={task!r}")
|
||||
iri = task.payload["iri"]
|
||||
url = task.payload["url"]
|
||||
try:
|
||||
MEDIA_CACHE.cache_emoji(url, iri)
|
||||
except Exception as exc:
|
||||
err = f"failed to cache emoji {url} at {iri}"
|
||||
app.logger.exception(err)
|
||||
raise TaskError() from exc
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
@blueprint.route("/task/forward_activity", methods=["POST"])
|
||||
def task_forward_activity() -> _Response:
|
||||
task = p.parse(flask.request)
|
||||
|
Reference in New Issue
Block a user