mirror of
https://github.com/ash-project/ash_hq.git
synced 2024-09-20 05:13:23 +12:00
chore: skip messages that fail to import
This commit is contained in:
parent
4b8206154a
commit
4689afa66b
1 changed files with 5 additions and 0 deletions
|
@ -4,6 +4,7 @@ defmodule AshHq.Discord.Poller do
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use GenServer
|
use GenServer
|
||||||
|
require Logger
|
||||||
|
|
||||||
@poll_interval :timer.hours(1)
|
@poll_interval :timer.hours(1)
|
||||||
@server_id 711_271_361_523_351_632
|
@server_id 711_271_361_523_351_632
|
||||||
|
@ -104,6 +105,7 @@ defmodule AshHq.Discord.Poller do
|
||||||
false
|
false
|
||||||
end)
|
end)
|
||||||
|> Enum.each(fn %{thread: thread, messages: messages} ->
|
|> Enum.each(fn %{thread: thread, messages: messages} ->
|
||||||
|
try do
|
||||||
author =
|
author =
|
||||||
messages
|
messages
|
||||||
|> Enum.min_by(& &1.timestamp, DateTime)
|
|> Enum.min_by(& &1.timestamp, DateTime)
|
||||||
|
@ -117,6 +119,9 @@ defmodule AshHq.Discord.Poller do
|
||||||
|> Map.put(:create_timestamp, thread.thread_metadata.create_timestamp)
|
|> Map.put(:create_timestamp, thread.thread_metadata.create_timestamp)
|
||||||
|> Map.put(:messages, Enum.map(messages, &Map.from_struct/1))
|
|> Map.put(:messages, Enum.map(messages, &Map.from_struct/1))
|
||||||
|> AshHq.Discord.Thread.upsert!()
|
|> AshHq.Discord.Thread.upsert!()
|
||||||
|
rescue
|
||||||
|
e ->
|
||||||
|
Logger.error("Failed to import message:\n #{Exception.format(:error, e, __STACKTRACE__)}")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue