diff --git a/api/aeris.cabal b/api/aeris.cabal index 78cf64f..0d391c0 100644 --- a/api/aeris.cabal +++ b/api/aeris.cabal @@ -22,6 +22,7 @@ extra-source-files: services/github.json services/spotify.json services/twitter.json + services/utils.json services/youtube.json source-repository head diff --git a/api/services/utils.json b/api/services/utils.json new file mode 100644 index 0000000..383db41 --- /dev/null +++ b/api/services/utils.json @@ -0,0 +1,19 @@ +{ + "name": "Utils", + "actions": [ + { + "name": "Utils_OnTrigger", + "label": { + "en": "Manual trigger", + "fr": "Déclencheur manuel" + }, + "description": { + "en": "Trigger only on dev interactions with Aeris.", + "fr": "Action se déclenchant uniquement lors d'une interaction manuelle" + }, + "params": [], + "returns": [] + } + ], + "reactions": [] +} diff --git a/api/src/Api/About.hs b/api/src/Api/About.hs index cdf06a9..e24446c 100644 --- a/api/src/Api/About.hs +++ b/api/src/Api/About.hs @@ -15,35 +15,21 @@ import Data.Aeson.TH (deriveJSON) import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) import GHC.Generics (Generic) import Network.Socket (SockAddr) -import Servant (Handler, RemoteHost, throwError, err500) +import Servant (Handler, RemoteHost, throwError, err500, ServerError(..)) import qualified Data.ByteString as S import qualified Data.ByteString.Lazy as L import Data.FileEmbed (embedDir, makeRelativeToProject) +import qualified Codec.Binary.UTF8.Generic as L data ClientAbout = ClientAbout { host :: String } deriving (Eq, Show) -data ActionAbout = ActionAbout - { name :: String - , description :: String - , params :: [Object] - , returns :: [Object] - } - deriving (Eq, Show) - -data ServicesAbout = ServicesAbout - { name :: String - , actions :: [ActionAbout] - , reactions :: [ActionAbout] - } - deriving (Eq, Show, Generic) - data ServerAbout = ServerAbout { current_time :: POSIXTime - , services :: [ServicesAbout] + , services :: [Object] } deriving (Eq, Show) @@ -54,18 +40,17 @@ data About = About deriving (Eq, Show) $(deriveJSON defaultOptions ''ClientAbout) -$(deriveJSON defaultOptions ''ActionAbout) -$(deriveJSON defaultOptions ''ServicesAbout) $(deriveJSON defaultOptions ''ServerAbout) $(deriveJSON defaultOptions ''About) servicesDir :: [(FilePath, S.ByteString)] servicesDir = $(embedDir "./services/") +-- servicesDir = undefined about :: SockAddr -> AppM About about host = do now <- liftIO getPOSIXTime - let d = traverse (eitherDecode . L.fromStrict . snd) servicesDir :: Either String [ServicesAbout] + let d = traverse (eitherDecode . L.fromStrict . snd) servicesDir :: Either String [Object] case d of - Left err -> throwError err500 + Left err -> throwError err500 { errBody = L.fromString err } Right services -> return $ About (ClientAbout $ show host) (ServerAbout now services) diff --git a/mobile/lib/src/models/service.dart b/mobile/lib/src/models/service.dart index c9048df..f963604 100644 --- a/mobile/lib/src/models/service.dart +++ b/mobile/lib/src/models/service.dart @@ -51,6 +51,10 @@ class Service { url = "https://youtube.com", logoUrl = "https://play-lh.googleusercontent.com/lMoItBgdPPVDJsNOVtP26EKHePkwBg-PkuY9NOrc-fumRtTFP4XhpUNk_22syN4Datc"; + const Service.utils() + : name = "Utils", + url = "", + logoUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cle.png/1024px-Cle.png"; /// Returns a list of all the available services static all() => const [ @@ -59,6 +63,7 @@ class Service { Service.gmail(), Service.youtube(), Service.twitter(), - Service.spotify() + Service.spotify(), + Service.utils(), ]; } diff --git a/web-app/src/pages/ServiceSetup.tsx b/web-app/src/pages/ServiceSetup.tsx index 2dc170b..c7f6b48 100644 --- a/web-app/src/pages/ServiceSetup.tsx +++ b/web-app/src/pages/ServiceSetup.tsx @@ -15,6 +15,7 @@ export interface ServiceSetupProps { export default function ServiceSetupModal({ services }: ServiceSetupProps) { const { t } = useTranslation(); + services = services.filter(x => x.uid !== "utils"); const unlinkedServices = services.filter(el => !el.linked); const linkedServices = services.filter(el => el.linked); return ( diff --git a/web-app/src/utils/globals.tsx b/web-app/src/utils/globals.tsx index 262f880..29d5e32 100644 --- a/web-app/src/utils/globals.tsx +++ b/web-app/src/utils/globals.tsx @@ -38,6 +38,10 @@ export const AppServicesLogos: { [key: string]: ImageProps } = { imageSrc: "https://anilist.co/img/icons/safari-pinned-tab.svg", altText: "AniList logo", }, + utils: { + imageSrc: "https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Cle.png/1024px-Cle.png", + altText: "Utils logo", + }, }; const getServiceUrl = (service: string) => @@ -86,6 +90,13 @@ export const AppServices: Array = [ urlAuth: getServiceUrl("anilist"), linked: false, }, + { + label: "Utils", + uid: "utils", + logo: AppServicesLogos["utils"], + urlAuth: "", + linked: false, + }, ]; export const NoAREA: AppAREAType = { diff --git a/web-app/src/utils/utils.tsx b/web-app/src/utils/utils.tsx index 51e380a..6e1fcff 100644 --- a/web-app/src/utils/utils.tsx +++ b/web-app/src/utils/utils.tsx @@ -87,7 +87,7 @@ export const deSerializeAREA = (dumpAREA: any, service: AppServiceType): AppAREA }; export const deSerializeService = (dumpService: any, services: Array): Array> => { - let service: AppServiceType = services.filter((el) => el.uid === dumpService.name.toLowerCase())[0] ?? services[0]; + let service: AppServiceType = services.find((el) => el.uid === dumpService.name.toLowerCase()) ?? services[0]; let actions: Array = dumpService.actions.map((el: any) => deSerializeAREA(el, service)); let reactions: Array = dumpService.reactions.map((el: any) => deSerializeAREA(el, service)); diff --git a/worker/src/actions.ts b/worker/src/actions.ts index f7a3f66..c2ec8fa 100644 --- a/worker/src/actions.ts +++ b/worker/src/actions.ts @@ -52,7 +52,7 @@ export class Manager { } handlePipelineError(pipeline: Pipeline, error: Error): Observable { - console.error(`Unhandled exception while trying to listen for the pipeline ${pipeline.name} (type: ${pipeline.type.toString()}).`, error) + console.error(`Unhandled exception while trying to listen for the pipeline ${pipeline.name} (type: ${pipeline.type?.toString()}).`, error) fetch(`${process.env["WORKER_API_URL"]}/error/${pipeline.id}?WORKER_API_KEY=${process.env["WORKER_API_KEY"]}`, { method: "POST", body: JSON.stringify({error}), diff --git a/worker/src/models/pipeline.ts b/worker/src/models/pipeline.ts index 37a3683..b24ffe5 100644 --- a/worker/src/models/pipeline.ts +++ b/worker/src/models/pipeline.ts @@ -111,6 +111,7 @@ export class PipelineEnv { export const pipelineFromApi = (data: any): Pipeline => { const type: string = data.res.action.pType; + console.log("type::", type); return { id: data.res.action.id, name: data.res.action.name, diff --git a/worker/src/services/index.ts b/worker/src/services/index.ts index 347f36a..687d5e7 100644 --- a/worker/src/services/index.ts +++ b/worker/src/services/index.ts @@ -4,3 +4,4 @@ export { Github } from "./github" export { Spotify } from "./spotify" export { Discord } from "./discord" export { Anilist } from "./anilist" +export { UtilsService } from "./utils"