From 9aeebf43c67be8eaff5f116609b9106872343704 Mon Sep 17 00:00:00 2001 From: Jack Rosa Date: Tue, 17 Sep 2024 16:02:32 -0400 Subject: [PATCH] refactor: remove extwitter and clean twitter module --- config/config.exs | 6 ------ lib/tilex/notifications/notifiers/twitter.ex | 10 ++++------ mix.exs | 1 - 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/config/config.exs b/config/config.exs index d05d96b8..f38bcf98 100644 --- a/config/config.exs +++ b/config/config.exs @@ -108,12 +108,6 @@ config :tilex, Tilex.Auth.Guardian, "kty" => "oct" } -config :extwitter, :oauth, - consumer_key: System.get_env("twitter_consumer_key"), - consumer_secret: System.get_env("twitter_consumer_secret"), - access_token: System.get_env("twitter_access_token"), - access_token_secret: System.get_env("twitter_access_token_secret") - # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/lib/tilex/notifications/notifiers/twitter.ex b/lib/tilex/notifications/notifiers/twitter.ex index dd2815fb..1bdf3aa6 100644 --- a/lib/tilex/notifications/notifiers/twitter.ex +++ b/lib/tilex/notifications/notifiers/twitter.ex @@ -3,7 +3,6 @@ defmodule Tilex.Notifications.Notifiers.Twitter do alias Tilex.Blog.Developer use Tilex.Notifications.Notifier - require Logger def handle_post_created(post, developer, channel, url) do "#{post.title} #{url} via @#{Developer.twitter_handle(developer)} #til ##{channel.twitter_hashtag}" @@ -18,18 +17,17 @@ defmodule Tilex.Notifications.Notifiers.Twitter do :ok end - def send_tweet(message) do - url = "https://api.x.com/2/tweets" + @tweets_url "https://api.x.com/2/tweets" + def send_tweet(message) do params = %{ "text" => message } headers = - oauth_headers("post", url) ++ - [{"Content-Type", "application/json"}] + oauth_headers("post", @tweets_url) - Req.post!(url, headers: headers, json: params) + Req.post!(@tweets_url, headers: headers, json: params) end defp oauth_headers(method, url) do diff --git a/mix.exs b/mix.exs index 628b6a98..30d13321 100644 --- a/mix.exs +++ b/mix.exs @@ -40,7 +40,6 @@ defmodule Tilex.Mixfile do {:earmark, "~> 1.4.4"}, {:ecto_sql, "~> 3.6"}, {:esbuild, "~> 0.4", runtime: Mix.env() == :dev}, - {:extwitter, "~> 0.13"}, {:floki, "~>0.34"}, {:gettext, "~> 0.18"}, {:guardian, "~> 2.0"},