mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
add additional live events
This commit is contained in:
parent
e38ea68260
commit
cec8b605a8
6 changed files with 41 additions and 1 deletions
|
@ -3,5 +3,11 @@ defmodule Philomena.ThumbnailWorker do
|
|||
|
||||
def perform(image_id) do
|
||||
Thumbnailer.generate_thumbnails(image_id)
|
||||
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"image:processed",
|
||||
%{image_id: image_id}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,6 +41,12 @@ defmodule PhilomenaWeb.Api.Json.ImageController do
|
|||
|
||||
case Images.create_image(attributes, image_params) do
|
||||
{:ok, %{image: image}} ->
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"image:create",
|
||||
PhilomenaWeb.Api.Json.ImageView.render("show.json", %{image: image, interactions: []})
|
||||
)
|
||||
|
||||
render(conn, "show.json", image: image, interactions: [])
|
||||
|
||||
{:error, :image, changeset, _} ->
|
||||
|
|
|
@ -103,6 +103,12 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
def update(conn, %{"comment" => comment_params}) do
|
||||
case Comments.update_comment(conn.assigns.comment, conn.assigns.current_user, comment_params) do
|
||||
{:ok, %{comment: comment}} ->
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"comment:update",
|
||||
PhilomenaWeb.Api.Json.CommentView.render("show.json", %{comment: comment})
|
||||
)
|
||||
|
||||
Comments.reindex_comment(comment)
|
||||
|
||||
conn
|
||||
|
|
|
@ -7,13 +7,25 @@ defmodule PhilomenaWeb.Image.DescriptionController do
|
|||
|
||||
plug PhilomenaWeb.FilterBannedUsersPlug
|
||||
plug PhilomenaWeb.CanaryMapPlug, update: :edit_description
|
||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true
|
||||
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true, preload: [:tags, :user]
|
||||
|
||||
def update(conn, %{"image" => image_params}) do
|
||||
image = conn.assigns.image
|
||||
old_description = image.description
|
||||
|
||||
case Images.update_description(image, image_params) do
|
||||
{:ok, image} ->
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"image:description_update",
|
||||
%{image_id: image.id, added: image.description, removed: old_description}
|
||||
)
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"image:update",
|
||||
PhilomenaWeb.Api.Json.ImageView.render("show.json", %{image: image, interactions: []})
|
||||
)
|
||||
|
||||
Images.reindex_image(image)
|
||||
|
||||
body = TextileRenderer.render_one(%{body: image.description}, conn)
|
||||
|
|
|
@ -21,6 +21,11 @@ defmodule PhilomenaWeb.Image.SourceController do
|
|||
|
||||
case Images.update_source(image, attributes, image_params) do
|
||||
{:ok, %{image: image}} ->
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"image:source_update",
|
||||
%{image_id: image.id, added: [image.source_url], removed: [old_source]}
|
||||
)
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"image:update",
|
||||
|
|
|
@ -22,6 +22,11 @@ defmodule PhilomenaWeb.Image.TagController do
|
|||
|
||||
case Images.update_tags(image, attributes, image_params) do
|
||||
{:ok, %{image: {image, added_tags, removed_tags}}} ->
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"image:tag_update",
|
||||
%{image_id: image.id, added: Enum.map(added_tags, & &1.name), removed: Enum.map(removed_tags, & &1.name)}
|
||||
)
|
||||
PhilomenaWeb.Endpoint.broadcast!(
|
||||
"firehose",
|
||||
"image:update",
|
||||
|
|
Loading…
Reference in a new issue