Skip to content

Commit 1a2d363

Browse files
committed
fix: Properly set untracked field on imported SP alters
1 parent 3d11894 commit 1a2d363

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎lib/octocon/workers/simply_plural_import_worker.ex‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,13 @@ defmodule Octocon.Workers.SimplyPluralImportWorker do
190190
{:ok, %{body: alters_body}} = send_sp_request(:get, "/members/#{id}", sp_token)
191191

192192
{alters, uuids, avatars} =
193-
(Jason.decode!(alters_body) ++ Jason.decode!(custom_fronts_body))
194-
|> Stream.map(&{&1["content"], &1["id"]})
193+
((Jason.decode!(alters_body) |> Enum.map(fn alter -> Map.put(alter, "type", :alter) end)) ++
194+
(Jason.decode!(custom_fronts_body)
195+
|> Enum.map(fn cf -> Map.put(cf, "type", :custom_front) end)))
196+
|> Stream.map(&{&1["content"], &1["id"], &1["type"]})
195197
|> Stream.with_index(start_count)
196-
|> Stream.map(fn {{alter, uuid}, index} ->
197-
{alter, avatar} = parse_alter(system_id, alter, index, field_associations)
198+
|> Stream.map(fn {{alter, uuid, type}, index} ->
199+
{alter, avatar} = parse_alter(system_id, alter, type, index, field_associations)
198200
{alter, uuid, avatar}
199201
end)
200202
|> Stream.map(fn {alter, uuid, avatar} ->
@@ -370,7 +372,7 @@ defmodule Octocon.Workers.SimplyPluralImportWorker do
370372
res
371373
end
372374

373-
defp parse_alter(system_id, alter, id, field_associations) do
375+
defp parse_alter(system_id, alter, type, id, field_associations) do
374376
{
375377
%Alter{
376378
user_id: system_id,
@@ -382,7 +384,7 @@ defmodule Octocon.Workers.SimplyPluralImportWorker do
382384
alias: nil,
383385
pinned: false,
384386
archived: false,
385-
untracked: alter["archived"] == nil,
387+
untracked: type == :custom_front,
386388
last_fronted: nil,
387389
fields:
388390
Enum.map(alter["info"] || [], fn {field_id, value} ->

0 commit comments

Comments
 (0)