neiam
/oh-my-ex-oh-ircd
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
Credo: auto-join channels filtered in the query
87dde30 · Gabe Morell · 2026-11-04 21:30
Files changed
modified
lib/oh_my_ex_oh_ircd/channels.ex
+6
−5
@@ -38,11 +38,12 @@ defmodule OhMyExOhIrcd.Channels do
| 38 | 38 | not survive and is not enumerable here. |
| 39 | 39 | """ |
| 40 | 40 | def auto_join_names do |
| 41 | − Repo.all(from c in ChannelRecord, order_by: [asc: c.name]) | |
| 42 | − |> Enum.filter(fn rec -> | |
| 43 | − (rec.modes || %{}) |> Map.get("flags", []) |> Enum.member?("auto_join") | |
| 44 | − end) | |
| 45 | − |> Enum.map(& &1.name) | |
| 41 | + Repo.all( | |
| 42 | + from c in ChannelRecord, | |
| 43 | + where: fragment("(? -> 'flags') @> '[\"auto_join\"]'::jsonb", c.modes), | |
| 44 | + order_by: [asc: c.name], | |
| 45 | + select: c.name | |
| 46 | + ) | |
| 46 | 47 | rescue |
| 47 | 48 | _ -> [] |
| 48 | 49 | end |
Parents: 9f703bd