- def maybe_external_user_query(query, external) do
- if external, do: external_user_query(query), else: query
- end
-
- def external_user_query(query \\ User) do
- from(
- u in query,
- where: u.local == false,
- where: not is_nil(u.nickname)
- )
- end
-
- def maybe_active_user_query(query, active) do
- if active, do: active_user_query(query), else: query
- end
-
- def active_user_query(query \\ User) do
- from(
- u in query,
- where: fragment("not (?->'deactivated' @> 'true')", u.info),
- where: not is_nil(u.nickname)
- )
- end
+ def deactivate(%User{} = user, status \\ true) do
+ info_cng = User.Info.set_activation_status(user.info, status)