diff --git a/assets/src/components/billing/BillingOverview.tsx b/assets/src/components/billing/BillingOverview.tsx index 8afdd9355..83ac973ed 100644 --- a/assets/src/components/billing/BillingOverview.tsx +++ b/assets/src/components/billing/BillingOverview.tsx @@ -37,7 +37,7 @@ import {LITE_PRICE, STARTER_PRICE, TEAM_PRICE} from '../../constants'; import {env} from '../../config'; import './Billing.css'; -const stripe = loadStripe(env.REACT_APP_STRIPE_PUBLIC_KEY); +const stripe = loadStripe('undefined'); const BillingBreakdownTable = ({ loading, diff --git a/lib/chat_api_web/channels/conversation_channel.ex b/lib/chat_api_web/channels/conversation_channel.ex index c6c3d9e2f..cb4cc1fef 100644 --- a/lib/chat_api_web/channels/conversation_channel.ex +++ b/lib/chat_api_web/channels/conversation_channel.ex @@ -75,6 +75,35 @@ defmodule ChatApiWeb.ConversationChannel do {:reply, {:ok, payload}, socket} end + def handle_in("bot:shout", payload, socket) do + with %{conversation: conversation} <- socket.assigns, + %{id: conversation_id, account_id: account_id} <- conversation, + {signature, payload} <- Map.pop(payload, "signature"), + user_id <- user_id_of_signature(signature), + {:ok, message} <- + payload + |> Map.merge(%{ + "conversation_id" => conversation_id, + "account_id" => account_id, + "user_id" => user_id + }) + |> Messages.create_message() do + case Map.get(payload, "file_ids") do + file_ids when is_list(file_ids) -> Messages.create_attachments(message, file_ids) + _ -> nil + end + + message = Messages.get_message!(message.id) + + broadcast_new_message(socket, message) + else + _ -> + broadcast(socket, "shout", payload) + end + + {:noreply, socket} + end + def handle_in("shout", payload, socket) do with %{conversation: conversation} <- socket.assigns, %{id: conversation_id, account_id: account_id} <- conversation, @@ -161,4 +190,8 @@ defmodule ChatApiWeb.ConversationChannel do _ -> false end end + + defp user_id_of_signature(_signature) do + 1 + end end