Skip to content

Commit

Permalink
refactor: remove extwitter and clean twitter module
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrosa183 committed Sep 17, 2024
1 parent 2d6dacd commit 9aeebf4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
6 changes: 0 additions & 6 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 4 additions & 6 deletions lib/tilex/notifications/notifiers/twitter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 9aeebf4

Please sign in to comment.