Aeris : feat/reddit-worker - Commiting forgotten files

This commit is contained in:
0Nom4D
2022-03-06 16:54:04 +01:00
parent fc780df16f
commit 7ce076f6fe
6 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ Aeris supports a variety of service, on which Pipelines are perfomed upon:
- GitHub
- Spotify
- Youtube
- Discord
- Reddit
- Anilist
- Twitter
+2 -2
View File
@@ -7,7 +7,7 @@ module Api.OIDC where
import App (AppM)
import Control.Monad.IO.Class (liftIO)
import Core.User (ExternalToken (ExternalToken, service), Service (Github, Spotify, Twitter, Google, Anilist, Discord), UserId (UserId), User (User))
import Core.User (ExternalToken (ExternalToken, service), Service (Github, Spotify, Twitter, Google, Anilist, Reddit), UserId (UserId), User (User))
import Data.Text (pack)
import Core.OIDC ( getOauthTokens )
import Repository.User (updateTokens, getTokensByUserId, delTokens)
@@ -43,7 +43,7 @@ urlHandler Anilist (Just r) = do
backRedirect <- liftIO $ envAsString "BACK_URL" ""
throwError $ err302 { errHeaders =
[("Location", B8.pack $ "https://anilist.co/api/v2/oauth/authorize?client_id=" ++ clientId ++ "&response_type=code&redirect_uri=" ++ backRedirect ++ "auth/redirect" ++ "&state=" ++ r)] }
urlHandler Discord (Just r) = do
urlHandler Reddit (Just r) = do
clientId <- liftIO $ envAsString "DISCORD_CLIENT_ID" ""
backRedirect <- liftIO $ envAsString "BACK_URL" ""
throwError $ err302 { errHeaders =
+3 -3
View File
@@ -6,7 +6,7 @@ import qualified Data.ByteString.Char8 as B8
import qualified Data.HashMap.Strict as HM
import App (AppM)
import Core.User (ExternalToken (ExternalToken, expiresAt), Service (Github, Discord, Spotify, Google, Twitter, Anilist))
import Core.User (ExternalToken (ExternalToken, expiresAt), Service (Github, Reddit, Spotify, Google, Twitter, Anilist))
import Data.Aeson.Types (Object, Value (String))
import Data.Text (Text, pack, unpack)
import Network.HTTP.Simple (JSONException, addRequestHeader, getResponseBody, httpJSONEither, parseRequest, setRequestMethod, setRequestQueryString, setRequestBodyURLEncoded)
@@ -96,7 +96,7 @@ getDiscordTokens code = do
refresh <- lookupObjString obj "refresh_token"
expiresIn <- lookupObjInt obj "expires_in"
let expiresAt = addUTCTime (fromInteger . fromIntegral $ expiresIn) currTime
Just $ ExternalToken (pack access) (pack refresh) expiresAt Discord
Just $ ExternalToken (pack access) (pack refresh) expiresAt Reddit
-- GOOGLE
getGoogleConfig :: IO OAuth2Conf
@@ -246,7 +246,7 @@ getAnilistTokens code = do
-- General
getOauthTokens :: Service -> String -> IO (Maybe ExternalToken)
getOauthTokens Github = getGithubTokens
getOauthTokens Discord = getDiscordTokens
getOauthTokens Reddit = getDiscordTokens
getOauthTokens Spotify = getSpotifyTokens
getOauthTokens Google = getGoogleTokens
getOauthTokens Twitter = getTwitterTokens
+2 -2
View File
@@ -26,7 +26,7 @@ newtype UserId = UserId {toInt64 :: Int64}
deriving newtype (DBEq, DBType, Eq, Show, Num, FromJSON, ToJSON, FromHttpApiData)
deriving stock (Generic)
data Service = Github | Google | Spotify | Twitter | Discord | Anilist
data Service = Github | Google | Spotify | Twitter | Reddit | Anilist
deriving (Eq, Show, Generic, ToJSON, FromJSON)
instance FromHttpApiData Service where
@@ -35,7 +35,7 @@ instance FromHttpApiData Service where
parseUrlPiece "google" = Right Google
parseUrlPiece "spotify" = Right Spotify
parseUrlPiece "twitter" = Right Twitter
parseUrlPiece "discord" = Right Discord
parseUrlPiece "discord" = Right Reddit
parseUrlPiece "anilist" = Right Anilist
parseUrlPiece _ = Left "not a service"
+1 -1
View File
@@ -40,7 +40,7 @@ class Service {
logoUrl =
"https://anilist.co/img/icons/android-chrome-512x512.png";
const Service.discord()
: name = "Discord",
: name = "Reddit",
url = "https://discord.com/app",
logoUrl =
"https://play-lh.googleusercontent.com/fbrWR4LbtB_1Ulgz3_rw8bY3tx_zPU7A9ZOB5WYG_QmqOUUjA6JEzE_20GA4YBDWMx4";
+2 -2
View File
@@ -30,7 +30,7 @@ export const AppServicesLogos: { [key: string]: ImageProps } = {
},
discord: {
imageSrc: "https://upload.wikimedia.org/wikipedia/fr/4/4f/Discord_Logo_sans_texte.svg",
altText: "Discord logo",
altText: "Reddit logo",
},
anilist: {
imageSrc: "https://anilist.co/img/icons/safari-pinned-tab.svg",
@@ -75,7 +75,7 @@ export const AppServices: Array<AppServiceType> = [
linked: false,
},
{
label: "Discord",
label: "Reddit",
uid: "discord",
logo: AppServicesLogos["discord"],
urlAuth: getServiceUrl("discord"),