Skip to content

Commit

Permalink
Merge pull request #448 from CaptainFact/staging
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
Betree authored Feb 7, 2024
2 parents 805f0bc + 0b965ad commit 74c2f3b
Show file tree
Hide file tree
Showing 25 changed files with 86 additions and 108 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center"><img src="https://avatars0.githubusercontent.com/u/28169525?s=200&v=4" height="100"/></p>
<h1 align="center"><a href="https://captainfact.io">CaptainFact.io</a></h1>
<p align="center">
<a href="https://discord.gg/2Qd7hMz" title="Discord"><img src="https://discordapp.com/api/guilds/416782744748687361/widget.png" alt="Discord"></a>
<a href="https://discord.captainfact.io" title="Discord"><img src="https://discordapp.com/api/guilds/416782744748687361/widget.png" alt="Discord"></a>
<a href="https://twitter.com/CaptainFact_io" title="Twitter"><img src="https://img.shields.io/twitter/follow/CaptainFact_io.svg?style=social&label=Follow"></a>
<a href="https://opencollective.com/captainfact_io" title="Backers on Open Collective"><img src="https://opencollective.com/captainfact_io/backers/badge.svg"></a>
</p>
Expand Down
4 changes: 0 additions & 4 deletions apps/cf/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ config :cf,

config :guardian, Guardian.DB, repo: DB.Repo

# Configure Rollbar (errors reporting)
config :rollbax,
enabled: :log

config :scout_apm,
name: "CaptainFact",
key: {:system, "CF_SCOUT_APM_KEY"}
Expand Down
4 changes: 0 additions & 4 deletions apps/cf/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ config :logger, :console, format: "[$level] $message\n"
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20

# Configure Rollbar (errors reporting)
config :rollbax,
environment: "dev"

# Mails
config :cf, CF.Mailer, adapter: Bamboo.LocalAdapter

Expand Down
5 changes: 0 additions & 5 deletions apps/cf/config/prod.exs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
use Mix.Config

# Configure Rollbar (errors reporting)
config :rollbax,
environment: "prod",
enable_crash_reports: true

# Do not print debug messages in production
config :logger, level: :info
4 changes: 0 additions & 4 deletions apps/cf/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,3 @@ config :bcrypt_elixir, :log_rounds, 4
# Behaviours mock for testing
config :cf, captions_fetcher: CF.Videos.CaptionsFetcherTest
config :cf, use_test_video_metadata_fetcher: true

# Configure Rollbar (errors reporting)
config :rollbax,
environment: "test"
15 changes: 6 additions & 9 deletions apps/cf/lib/errors/errors.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
defmodule CF.Errors do
@moduledoc """
Module to report errors, currenctly plugged on Rollbar with important metadata
added. It mostly mimics `Rollbax` API.
Module to report errors
"""

require Logger

@type cf_error_params :: [
user: DB.Schema.User.t(),
custom: Map.t(),
Expand Down Expand Up @@ -36,13 +37,9 @@ defmodule CF.Errors do

@spec do_report(:error | :exit | :throw, any(), [any()], cf_error_params()) :: :ok
def do_report(type, value, stacktrace, params) do
Rollbax.report(
type,
value,
stacktrace,
params[:custom] || %{},
build_occurence_data(params)
)
# Any call to Sentry, Rollbar, etc. should be done here
Logger.error("[ERROR][#{type}] #{inspect(value)} - #{inspect(stacktrace)}")
:ok
end

defp build_occurence_data(params) do
Expand Down
4 changes: 2 additions & 2 deletions apps/cf/lib/mailer/templates/_layout.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<ul style="font-family: Ubuntu, Lato, Tahoma, sans-serif;">
<li><a href="https://forum.captainfact.io/">Forum</a></li>
<li><a href="https://opencollective.com/captainfact_io">OpenCollective (Dons)</a></li>
<li><a href="https://discord.gg/2Qd7hMz">Discord</a></li>
<li><a href="https://discord.captainfact.io">Discord</a></li>
<li><a href="https://github.com/CaptainFact">Github</a></li>
<li><a href="https://www.facebook.com/CaptainFact.io/">Facebook</a></li>
<li><a href="https://twitter.com/CaptainFact_io">Twitter</a></li>
Expand Down Expand Up @@ -232,4 +232,4 @@
<![endif]-->
</div>
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion apps/cf/lib/mailer/templates/_layout.text.eex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= gettext_mail("If you like it, please share the word!") %>

Forum: https://forum.captainfact.io/
Discord: https://discord.gg/2Qd7hMz
Discord: https://discord.captainfact.io
Github: https://github.com/CaptainFact
Facebook: https://www.facebook.com/CaptainFact.io/
Twitter: https://twitter.com/CaptainFact_io
9 changes: 4 additions & 5 deletions apps/cf/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule CF.Mixfile do
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "~> 1.3.0", override: true},
{:phoenix, "~> 1.4.18", override: true},
{:phoenix_html, "~> 2.6"},
{:gettext, "~> 0.13.1"},
{:google_api_you_tube, "~> 0.42.0"},
Expand All @@ -55,10 +55,9 @@ defmodule CF.Mixfile do
{:bamboo, "~> 1.7.1"},
{:hackney, "~> 1.17"},
{:oauth2, "~> 0.9"},
{:rollbax, ">= 0.0.0"},
{:sweet_xml, "~> 0.6"},
{:burnex, "~> 1.0"},
{:yaml_elixir, "~> 2.4.0"},
{:burnex, "~> 3.1"},
{:yaml_elixir, "~> 2.9.0"},
{:scout_apm, "~> 1.0.6"},

# ---- Internal ----
Expand All @@ -68,7 +67,7 @@ defmodule CF.Mixfile do
{:exsync, "~> 0.2", only: :dev},

# Test only
{:bypass, "~> 0.8", only: :test},
{:bypass, "~> 2.1.0", only: :test},
{:mock, "~> 0.3.1", only: :test}
]
end
Expand Down
2 changes: 1 addition & 1 deletion apps/cf_atom_feed/lib/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule CF.AtomFeed.Router do
def start_link do
config = Application.get_env(:cf_atom_feed, CF.AtomFeed.Router)
Logger.info("Running CF.AtomFeed.Router with cowboy on port #{config[:cowboy][:port]}")
Plug.Adapters.Cowboy.http(CF.AtomFeed.Router, [], config[:cowboy])
Plug.Cowboy.http(CF.AtomFeed.Router, [], config[:cowboy])
end

get "/" do
Expand Down
4 changes: 2 additions & 2 deletions apps/cf_atom_feed/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ defmodule CF.AtomFeed.Mixfile do
[
# --- Runtime
{:atomex, "~> 0.2"},
{:cowboy, "~> 1.0"},
{:plug, "~> 1.0"},
{:cowboy, "~> 2.0"},
{:plug, "~> 1.7"},
{:kaur, "~> 1.1"},

# ---- In Umbrella
Expand Down
1 change: 1 addition & 0 deletions apps/cf_graphql/lib/resolvers/app_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule CF.Graphql.Resolvers.AppInfo do
def info(_, _args, _info) do
{:ok,
%{
app: "CF.Graphql",
status: "✔",
version: CF.Graphql.Application.version(),
db_version: DB.Application.version()
Expand Down
8 changes: 4 additions & 4 deletions apps/cf_graphql/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ defmodule CF.Graphql.Mixfile do

defp deps do
[
{:phoenix, "~> 1.3.0"},
{:plug, "~> 1.0"},
{:phoenix, "~> 1.4.18"},
{:plug, "~> 1.7"},
{:phoenix_pubsub, "~> 1.0"},
{:cowboy, "~> 1.0"},
{:corsica, "~> 1.0"},
{:cowboy, "~> 2.0"},
{:corsica, "~> 2.1"},
{:absinthe_ecto, "~> 0.1.3"},
{:absinthe_plug, "~> 1.4.1"},
{:kaur, "~> 1.1"},
Expand Down
4 changes: 0 additions & 4 deletions apps/cf_rest_api/lib/channels/user_socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ defmodule CF.RestApi.UserSocket do
channel("statements:video:*", CF.RestApi.StatementsChannel)
channel("comments:video:*", CF.RestApi.CommentsChannel)

## Transports
transport(:websocket, Phoenix.Transports.WebSocket)
transport(:longpoll, Phoenix.Transports.LongPoll)

# Connect with token
def connect(%{"token" => token}, socket) do
case authenticate(socket, GuardianImpl, token) do
Expand Down
1 change: 1 addition & 0 deletions apps/cf_rest_api/lib/controllers/api_info_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule CF.RestApi.ApiInfoController do
conn
|> put_status(:ok)
|> json(%{
app: "CF.RestApi",
status: "✔",
version: CF.Application.version(),
db_version: DB.Application.version()
Expand Down
2 changes: 1 addition & 1 deletion apps/cf_rest_api/lib/endpoint.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule CF.RestApi.Endpoint do
use Phoenix.Endpoint, otp_app: :cf_rest_api

socket("/socket", CF.RestApi.UserSocket)
socket("/socket", CF.RestApi.UserSocket, websocket: true, longpoll: false)

if Application.get_env(:arc, :storage) == Arc.Storage.Local,
do: plug(Plug.Static, at: "/resources", from: "./resources", gzip: false)
Expand Down
8 changes: 4 additions & 4 deletions apps/cf_rest_api/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ defmodule CF.RestApi.Mixfile do
# Dependencies
defp deps do
[
{:corsica, "~> 1.0"},
{:cowboy, "~> 1.0"},
{:corsica, "~> 2.1"},
{:cowboy, "~> 2.0"},
{:gettext, "~> 0.13.1"},
{:kaur, "~> 1.1"},
{:phoenix, "~> 1.3.0", override: true},
{:phoenix, "~> 1.4.18", override: true},
{:phoenix_html, "~> 2.6"},
{:phoenix_pubsub, "~> 1.0"},
{:poison, "~> 3.1"},
{:scout_apm, "~> 1.0.6"},
{:plug_cowboy, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},

# ---- Internal ----
{:cf, in_umbrella: true},
Expand Down
9 changes: 7 additions & 2 deletions apps/cf_rest_api/test/channels/comments_channel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ defmodule CF.RestApi.CommentsChannelTest do
end

test "Get comments when connecting", %{comments: comments, topic: topic} do
{:ok, response, _} = subscribe_and_join(socket("", %{user_id: nil}), CommentsChannel, topic)
{:ok, response, _} =
subscribe_and_join(
socket(CF.RestApi.UserSocket, "", %{user_id: nil}),
CommentsChannel,
topic
)

assert Enum.count(response.comments) == Enum.count(comments)
end
Expand All @@ -27,7 +32,7 @@ defmodule CF.RestApi.CommentsChannelTest do
# Connect to socket
{:ok, _, socket} =
subscribe_and_join(
socket("", %{user_id: user.id}),
socket(CF.RestApi.UserSocket, "", %{user_id: user.id}),
CommentsChannel,
topic
)
Expand Down
4 changes: 2 additions & 2 deletions apps/cf_rest_api/test/channels/video_debate_channel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule CF.RestApi.VideoDebateChannelTest do

{:ok, returned_video, socket} =
subscribe_and_join(
socket("", %{user_id: nil}),
socket(CF.RestApi.UserSocket, "", %{user_id: nil}),
VideoDebateChannel,
"video_debate:#{video.hash_id}"
)
Expand All @@ -26,7 +26,7 @@ defmodule CF.RestApi.VideoDebateChannelTest do

{:ok, _, authed_socket} =
subscribe_and_join(
socket("", %{user_id: insert(:user, %{reputation: 5000}).id}),
socket(CF.RestApi.UserSocket, "", %{user_id: insert(:user, %{reputation: 5000}).id}),
VideoDebateChannel,
topic
)
Expand Down
30 changes: 16 additions & 14 deletions apps/cf_reverse_proxy/lib/application.ex
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
defmodule CF.ReverseProxy.Application do
use Application

require Logger

def start(_type, _args) do
import Supervisor.Spec, warn: false
port = Application.get_env(:cf_reverse_proxy, :port)

websocket =
{Phoenix.Transports.WebSocket, {CF.RestApi.Endpoint, CF.RestApi.UserSocket, :websocket}}

cowboy_options = [
port: port,
dispatch: [
{:_,
[
{"/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, websocket},
{:_, Plug.Adapters.Cowboy.Handler, {CF.ReverseProxy.Plug, []}}
]}
]
]
cowboy =
{Plug.Cowboy,
scheme: :http,
plug: CF.ReverseProxy.Plug,
port: port,
dispatch: [
{:_,
[
{"/socket/websocket", Phoenix.Endpoint.Cowboy2Handler, {CF.RestApi.Endpoint, []}},
{"/socket/longpoll", Phoenix.Endpoint.Cowboy2Handler, {CF.RestApi.Endpoint, []}},
{:_, Plug.Cowboy.Handler, {CF.ReverseProxy.Plug, []}}
]}
]}

cowboy = Plug.Adapters.Cowboy.child_spec(:http, CF.ReverseProxy.Plug, [], cowboy_options)
Logger.info("Running CF.ReverseProxy with cowboy on port #{port}")
opts = [strategy: :one_for_one, name: CF.ReverseProxy.Supervisor]
Supervisor.start_link([cowboy], opts)
end
Expand Down
6 changes: 3 additions & 3 deletions apps/cf_reverse_proxy/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ defmodule CF.ReverseProxy.Mixfile do
{:cf_rest_api, in_umbrella: true},
{:cf_graphql, in_umbrella: true},
{:cf_atom_feed, in_umbrella: true},
{:phoenix, "~> 1.3.0"},
{:cowboy, "~> 1.0"},
{:corsica, "~> 1.0"}
{:phoenix, "~> 1.4.18"},
{:cowboy, "~> 2.0"},
{:corsica, "~> 2.1"}
]
end

Expand Down
2 changes: 1 addition & 1 deletion apps/db/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ defmodule DB.Mixfile do
{:slugger, "~> 0.2"},
{:comeonin, "~> 4.1.1"},
{:bcrypt_elixir, "~> 1.0"},
{:burnex, "~> 1.0"},
{:burnex, "~> 3.1"},
{:hashids, "~> 2.0"},
{:kaur, "~> 1.1"},
{:mime, "~> 1.2"},
Expand Down
8 changes: 0 additions & 8 deletions config/releases.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ end
# ---- [Global config keys] ----

frontend_url = String.trim_trailing(load_secret.("frontend_url")) <> "/"
rollbar_access_token = load_secret.({"rollbar_access_token", nil})

if rollbar_access_token do
config :rollbax,
enabled: true,
access_token: rollbar_access_token,
environment: load_secret.({"rollbar_environment", "production"})
end

# ---- [APP CONFIG] :db ----

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule CF.Umbrella.Mixfile do
# ---- Test and Dev
{:excoveralls, "~> 0.12.1", only: :test},
{:credo, "~> 1.1.0", only: [:dev, :test], runtime: false},
{:mix_test_watch, "~> 0.6", only: :dev, runtime: false}
{:mix_test_watch, "~> 1.1", only: :dev, runtime: false}
]
end

Expand Down
Loading

0 comments on commit 74c2f3b

Please sign in to comment.