commit
208c13bc5c
@ -0,0 +1 @@
|
||||
dist-newstyle/
|
@ -0,0 +1,46 @@
|
||||
module Main where
|
||||
|
||||
import Data.Aeson qualified as Aeson (Object)
|
||||
import Network.HTTP.Client.TLS (newTlsManager)
|
||||
import Servant.API (type (:<|>) ((:<|>)))
|
||||
import Servant.Client (BaseUrl (BaseUrl), ClientM, Scheme (Https), client, mkClientEnv, runClientM)
|
||||
import Servant.Misskey qualified as Misskey (Api)
|
||||
import Servant.Misskey.ActivityPub qualified as Misskey (ApShowResponse)
|
||||
import Servant.Misskey.Common (
|
||||
Authenticated (Authenticated),
|
||||
Note,
|
||||
Notification,
|
||||
UriRequest,
|
||||
UserLite,
|
||||
)
|
||||
import Servant.Misskey.Notes qualified as Misskey (NotesTimelineRequest, defaultNotesTimelineRequest)
|
||||
import Servant.Misskey.Notes qualified as Notes (NotesTimelineRequest (limit))
|
||||
import Servant.Misskey.Self qualified as Misskey (SelfNotificationsRequest, defaultSelfNotificationsRequest)
|
||||
import Servant.Misskey.Self qualified as Self (SelfNotificationsRequest (limit))
|
||||
import Servant.Misskey.Users qualified as Misskey (UsersShowRequest)
|
||||
import System.Environment (getEnv)
|
||||
|
||||
apGet ::
|
||||
Authenticated UriRequest ->
|
||||
ClientM Aeson.Object
|
||||
apShow :: Authenticated UriRequest -> ClientM Misskey.ApShowResponse
|
||||
self :: Authenticated (Proxy ()) -> ClientM UserLite
|
||||
notifications :: Authenticated Misskey.SelfNotificationsRequest -> ClientM [Notification]
|
||||
timeline :: Authenticated Misskey.NotesTimelineRequest -> ClientM [Note]
|
||||
usersShow :: Misskey.UsersShowRequest -> ClientM UserLite
|
||||
(apGet :<|> apShow) :<|> (self :<|> notifications) :<|> timeline :<|> usersShow = client (Proxy @Misskey.Api)
|
||||
|
||||
queries :: Text -> ClientM ()
|
||||
queries token = do
|
||||
print =<< self (a Proxy)
|
||||
print =<< notifications (a Misskey.defaultSelfNotificationsRequest {Self.limit = Just 1})
|
||||
print =<< timeline (a Misskey.defaultNotesTimelineRequest {Notes.limit = Just 1})
|
||||
where
|
||||
a :: a -> Authenticated a
|
||||
a = Authenticated token
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
token <- toText <$> getEnv "MISSKEY_TOKEN"
|
||||
manager <- newTlsManager
|
||||
print =<< runClientM (queries token) (mkClientEnv manager (BaseUrl Https "shitpost.poridge.club" 443 ""))
|
@ -0,0 +1,923 @@
|
||||
{
|
||||
"nodes": {
|
||||
"HTTP": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1451647621,
|
||||
"narHash": "sha256-oHIyw3x0iKBexEo49YeUDV1k74ZtyYKGR2gNJXXRxts=",
|
||||
"owner": "phadej",
|
||||
"repo": "HTTP",
|
||||
"rev": "9bc0996d412fef1787449d841277ef663ad9a915",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "phadej",
|
||||
"repo": "HTTP",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"blank": {
|
||||
"locked": {
|
||||
"lastModified": 1625557891,
|
||||
"narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=",
|
||||
"owner": "divnix",
|
||||
"repo": "blank",
|
||||
"rev": "5a5d2684073d9f563072ed07c871d577a6c614a8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "blank",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"cabal-32": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1603716527,
|
||||
"narHash": "sha256-X0TFfdD4KZpwl0Zr6x+PLxUt/VyKQfX7ylXHdmZIL+w=",
|
||||
"owner": "haskell",
|
||||
"repo": "cabal",
|
||||
"rev": "48bf10787e27364730dd37a42b603cee8d6af7ee",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "haskell",
|
||||
"ref": "3.2",
|
||||
"repo": "cabal",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"cabal-34": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1645834128,
|
||||
"narHash": "sha256-wG3d+dOt14z8+ydz4SL7pwGfe7SiimxcD/LOuPCV6xM=",
|
||||
"owner": "haskell",
|
||||
"repo": "cabal",
|
||||
"rev": "5ff598c67f53f7c4f48e31d722ba37172230c462",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "haskell",
|
||||
"ref": "3.4",
|
||||
"repo": "cabal",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"cabal-36": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1669081697,
|
||||
"narHash": "sha256-I5or+V7LZvMxfbYgZATU4awzkicBwwok4mVoje+sGmU=",
|
||||
"owner": "haskell",
|
||||
"repo": "cabal",
|
||||
"rev": "8fd619e33d34924a94e691c5fea2c42f0fc7f144",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "haskell",
|
||||
"ref": "3.6",
|
||||
"repo": "cabal",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"cardano-shell": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1608537748,
|
||||
"narHash": "sha256-PulY1GfiMgKVnBci3ex4ptk2UNYMXqGjJOxcPy2KYT4=",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "cardano-shell",
|
||||
"rev": "9392c75087cb9a3d453998f4230930dea3a95725",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "input-output-hk",
|
||||
"repo": "cardano-shell",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1663445644,
|
||||
"narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"dmerge": {
|
||||
"inputs": {
|
||||
"nixlib": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
],
|
||||
"yants": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"yants"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1659548052,
|
||||
"narHash": "sha256-fzI2gp1skGA8mQo/FBFrUAtY0GQkAIAaV/V127TJPyY=",
|
||||
"owner": "divnix",
|
||||
"repo": "data-merge",
|
||||
"rev": "d160d18ce7b1a45b88344aa3f13ed1163954b497",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "data-merge",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1672831974,
|
||||
"narHash": "sha256-z9k3MfslLjWQfnjBtEtJZdq3H7kyi2kQtUThfTgdRk0=",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "flake-compat",
|
||||
"rev": "45f2638735f8cdc40fe302742b79f248d23eb368",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "input-output-hk",
|
||||
"ref": "hkm/gitlab-fix",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_2": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1650374568,
|
||||
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_4": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"ghc-8.6.5-iohk": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1600920045,
|
||||
"narHash": "sha256-DO6kxJz248djebZLpSzTGD6s8WRpNI9BTwUeOf5RwY8=",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "ghc",
|
||||
"rev": "95713a6ecce4551240da7c96b6176f980af75cae",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "input-output-hk",
|
||||
"ref": "release/8.6.5-iohk",
|
||||
"repo": "ghc",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gomod2nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"utils": "utils"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1655245309,
|
||||
"narHash": "sha256-d/YPoQ/vFn1+GTmSdvbSBSTOai61FONxB4+Lt6w/IVI=",
|
||||
"owner": "tweag",
|
||||
"repo": "gomod2nix",
|
||||
"rev": "40d32f82fc60d66402eb0972e6e368aeab3faf58",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "tweag",
|
||||
"repo": "gomod2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hackage": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1677284793,
|
||||
"narHash": "sha256-4/W80Cv1uXvi9qM18CKi5OKumiw+p9FV04uKvW8gqXk=",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "hackage.nix",
|
||||
"rev": "b82ebaa0234ec2176748e87044750758c4ac4cfb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "input-output-hk",
|
||||
"repo": "hackage.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"haskellNix": {
|
||||
"inputs": {
|
||||
"HTTP": "HTTP",
|
||||
"cabal-32": "cabal-32",
|
||||
"cabal-34": "cabal-34",
|
||||
"cabal-36": "cabal-36",
|
||||
"cardano-shell": "cardano-shell",
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"ghc-8.6.5-iohk": "ghc-8.6.5-iohk",
|
||||
"hackage": "hackage",
|
||||
"hpc-coveralls": "hpc-coveralls",
|
||||
"hydra": "hydra",
|
||||
"iserv-proxy": "iserv-proxy",
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"nixpkgs-unstable"
|
||||
],
|
||||
"nixpkgs-2003": "nixpkgs-2003",
|
||||
"nixpkgs-2105": "nixpkgs-2105",
|
||||
"nixpkgs-2111": "nixpkgs-2111",
|
||||
"nixpkgs-2205": "nixpkgs-2205",
|
||||
"nixpkgs-2211": "nixpkgs-2211",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||
"old-ghc-nix": "old-ghc-nix",
|
||||
"stackage": "stackage",
|
||||
"tullia": "tullia"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1677286287,
|
||||
"narHash": "sha256-DUoduM2v8P+JcuPvAxnqvmHUk+I9r6rsEPUmtLyoE7w=",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "haskell.nix",
|
||||
"rev": "fc8852afce751eaab557f218124546e7f2e53374",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "input-output-hk",
|
||||
"repo": "haskell.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hpc-coveralls": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1607498076,
|
||||
"narHash": "sha256-8uqsEtivphgZWYeUo5RDUhp6bO9j2vaaProQxHBltQk=",
|
||||
"owner": "sevanspowell",
|
||||
"repo": "hpc-coveralls",
|
||||
"rev": "14df0f7d229f4cd2e79f8eabb1a740097fdfa430",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "sevanspowell",
|
||||
"repo": "hpc-coveralls",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hydra": {
|
||||
"inputs": {
|
||||
"nix": "nix",
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"hydra",
|
||||
"nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1671755331,
|
||||
"narHash": "sha256-hXsgJj0Cy0ZiCiYdW2OdBz5WmFyOMKuw4zyxKpgUKm4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "hydra",
|
||||
"rev": "f48f00ee6d5727ae3e488cbf9ce157460853fea8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "hydra",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"incl": {
|
||||
"inputs": {
|
||||
"nixlib": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669263024,
|
||||
"narHash": "sha256-E/+23NKtxAqYG/0ydYgxlgarKnxmDbg6rCMWnOBqn9Q=",
|
||||
"owner": "divnix",
|
||||
"repo": "incl",
|
||||
"rev": "ce7bebaee048e4cd7ebdb4cee7885e00c4e2abca",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "incl",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"iserv-proxy": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1670983692,
|
||||
"narHash": "sha256-avLo34JnI9HNyOuauK5R69usJm+GfW3MlyGlYxZhTgY=",
|
||||
"ref": "hkm/remote-iserv",
|
||||
"rev": "50d0abb3317ac439a4e7495b185a64af9b7b9300",
|
||||
"revCount": 10,
|
||||
"type": "git",
|
||||
"url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git"
|
||||
},
|
||||
"original": {
|
||||
"ref": "hkm/remote-iserv",
|
||||
"type": "git",
|
||||
"url": "https://gitlab.haskell.org/hamishmack/iserv-proxy.git"
|
||||
}
|
||||
},
|
||||
"lowdown-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1633514407,
|
||||
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
|
||||
"owner": "kristapsdz",
|
||||
"repo": "lowdown",
|
||||
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kristapsdz",
|
||||
"repo": "lowdown",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"n2c": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1665039323,
|
||||
"narHash": "sha256-SAh3ZjFGsaCI8FRzXQyp56qcGdAqgKEfJWPCQ0Sr7tQ=",
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"rev": "b008fe329ffb59b67bf9e7b08ede6ee792f2741a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix": {
|
||||
"inputs": {
|
||||
"lowdown-src": "lowdown-src",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-regression": "nixpkgs-regression"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1661606874,
|
||||
"narHash": "sha256-9+rpYzI+SmxJn+EbYxjGv68Ucp22bdFUSy/4LkHkkDQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nix",
|
||||
"rev": "11e45768b34fdafdcf019ddbd337afa16127ff0f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "2.11.0",
|
||||
"repo": "nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-nomad": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
"flake-utils": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"nix2container",
|
||||
"flake-utils"
|
||||
],
|
||||
"gomod2nix": "gomod2nix",
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"nixpkgs"
|
||||
],
|
||||
"nixpkgs-lib": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1658277770,
|
||||
"narHash": "sha256-T/PgG3wUn8Z2rnzfxf2VqlR1CBjInPE0l1yVzXxPnt0=",
|
||||
"owner": "tristanpemble",
|
||||
"repo": "nix-nomad",
|
||||
"rev": "054adcbdd0a836ae1c20951b67ed549131fd2d70",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "tristanpemble",
|
||||
"repo": "nix-nomad",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix2container": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1658567952,
|
||||
"narHash": "sha256-XZ4ETYAMU7XcpEeAFP3NOl9yDXNuZAen/aIJ84G+VgA=",
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"rev": "60bb43d405991c1378baf15a40b5811a53e32ffa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nlewo",
|
||||
"repo": "nix2container",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixago": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixago-exts": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1661824785,
|
||||
"narHash": "sha256-/PnwdWoO/JugJZHtDUioQp3uRiWeXHUdgvoyNbXesz8=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"rev": "8c1f9e5f1578d4b2ea989f618588d62a335083c3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixago",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1657693803,
|
||||
"narHash": "sha256-G++2CJ9u0E7NNTAi9n5G8TdDmGJXcIjkJ3NF8cetQB8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "365e1b3a859281cf11b94f87231adeabbdd878a2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-22.05-small",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-2003": {
|
||||
"locked": {
|
||||
"lastModified": 1620055814,
|
||||
"narHash": "sha256-8LEHoYSJiL901bTMVatq+rf8y7QtWuZhwwpKE2fyaRY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1db42b7fe3878f3f5f7a4f2dc210772fd080e205",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-20.03-darwin",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-2105": {
|
||||
"locked": {
|
||||
"lastModified": 1659914493,
|
||||
"narHash": "sha256-lkA5X3VNMKirvA+SUzvEhfA7XquWLci+CGi505YFAIs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "022caabb5f2265ad4006c1fa5b1ebe69fb0c3faf",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-21.05-darwin",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-2111": {
|
||||
"locked": {
|
||||
"lastModified": 1659446231,
|
||||
"narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "eabc38219184cc3e04a974fe31857d8e0eac098d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-21.11-darwin",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-2205": {
|
||||
"locked": {
|
||||
"lastModified": 1672580127,
|
||||
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0874168639713f547c05947c76124f78441ea46c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-22.05-darwin",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-2211": {
|
||||
"locked": {
|
||||
"lastModified": 1675730325,
|
||||
"narHash": "sha256-uNvD7fzO5hNlltNQUAFBPlcEjNG5Gkbhl/ROiX+GZU4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b7ce17b1ebf600a72178f6302c77b6382d09323f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-22.11-darwin",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-regression": {
|
||||
"locked": {
|
||||
"lastModified": 1643052045,
|
||||
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1675758091,
|
||||
"narHash": "sha256-7gFSQbSVAFUHtGCNHPF7mPc5CcqDk9M2+inlVPZSneg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "747927516efcb5e31ba03b7ff32f61f6d47e7d87",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1653581809,
|
||||
"narHash": "sha256-Uvka0V5MTGbeOfWte25+tfRL3moECDh1VwokWSZUdoY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "83658b28fe638a170a19b8933aa008b30640fbd1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1654807842,
|
||||
"narHash": "sha256-ADymZpr6LuTEBXcy6RtFHcUZdjKTBRTMYwu19WOx17E=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "fc909087cc3386955f21b4665731dbdaceefb1d8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1665087388,
|
||||
"narHash": "sha256-FZFPuW9NWHJteATOf79rZfwfRn5fE0wi9kRzvGfDHPA=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "95fda953f6db2e9496d2682c4fc7b82f959878f7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nosys": {
|
||||
"locked": {
|
||||
"lastModified": 1667881534,
|
||||
"narHash": "sha256-FhwJ15uPLRsvaxtt/bNuqE/ykMpNAPF0upozFKhTtXM=",
|
||||
"owner": "divnix",
|
||||
"repo": "nosys",
|
||||
"rev": "2d0d5207f6a230e9d0f660903f8db9807b54814f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "nosys",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"old-ghc-nix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1631092763,
|
||||
"narHash": "sha256-sIKgO+z7tj4lw3u6oBZxqIhDrzSkvpHtv0Kki+lh9Fg=",
|
||||
"owner": "angerman",
|
||||
"repo": "old-ghc-nix",
|
||||
"rev": "af48a7a7353e418119b6dfe3cd1463a657f342b8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "angerman",
|
||||
"ref": "master",
|
||||
"repo": "old-ghc-nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"haskellNix": "haskellNix",
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"nixpkgs-unstable"
|
||||
]
|
||||
}
|
||||
},
|
||||
"stackage": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1677197430,
|
||||
"narHash": "sha256-6B7i8OHDXhNAugIgyCR86xpvik8rY5yVEbZ1/lUq7tI=",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "stackage.nix",
|
||||
"rev": "edbf9a66650560899643547ac7465aac0073395a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "input-output-hk",
|
||||
"repo": "stackage.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"std": {
|
||||
"inputs": {
|
||||
"arion": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"blank": "blank",
|
||||
"devshell": "devshell",
|
||||
"dmerge": "dmerge",
|
||||
"flake-utils": "flake-utils_4",
|
||||
"incl": "incl",
|
||||
"makes": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"microvm": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"blank"
|
||||
],
|
||||
"n2c": "n2c",
|
||||
"nixago": "nixago",
|
||||
"nixpkgs": "nixpkgs_4",
|
||||
"nosys": "nosys",
|
||||
"yants": "yants"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1674526466,
|
||||
"narHash": "sha256-tMTaS0bqLx6VJ+K+ZT6xqsXNpzvSXJTmogkraBGzymg=",
|
||||
"owner": "divnix",
|
||||
"repo": "std",
|
||||
"rev": "516387e3d8d059b50e742a2ff1909ed3c8f82826",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "std",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"tullia": {
|
||||
"inputs": {
|
||||
"nix-nomad": "nix-nomad",
|
||||
"nix2container": "nix2container",
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"nixpkgs"
|
||||
],
|
||||
"std": "std"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1675695930,
|
||||
"narHash": "sha256-B7rEZ/DBUMlK1AcJ9ajnAPPxqXY6zW2SBX+51bZV0Ac=",
|
||||
"owner": "input-output-hk",
|
||||
"repo": "tullia",
|
||||
"rev": "621365f2c725608f381b3ad5b57afef389fd4c31",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "input-output-hk",
|
||||
"repo": "tullia",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1653893745,
|
||||
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"yants": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"haskellNix",
|
||||
"tullia",
|
||||
"std",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1667096281,
|
||||
"narHash": "sha256-wRRec6ze0gJHmGn6m57/zhz/Kdvp9HS4Nl5fkQ+uIuA=",
|
||||
"owner": "divnix",
|
||||
"repo": "yants",
|
||||
"rev": "d18f356ec25cb94dc9c275870c3a7927a10f8c3c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "yants",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
{
|
||||
# This is a template created by `hix init`
|
||||
inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
|
||||
inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
outputs = { self, nixpkgs, flake-utils, haskellNix }:
|
||||
let
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
in
|
||||
flake-utils.lib.eachSystem supportedSystems (system:
|
||||
let
|
||||
overlays = [ haskellNix.overlay
|
||||
(final: prev: {
|
||||
hixProject =
|
||||
final.haskell-nix.hix.project {
|
||||
src = ./.;
|
||||
evalSystem = "x86_64-linux";
|
||||
};
|
||||
})
|
||||
];
|
||||
pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };
|
||||
flake = pkgs.hixProject.flake {};
|
||||
in flake // {
|
||||
legacyPackages = pkgs;
|
||||
formatter =
|
||||
let
|
||||
inherit (pkgs.hixProject.tools { fourmolu = "latest"; }) fourmolu;
|
||||
in
|
||||
pkgs.writeScriptBin "fourmolu-inline" ''
|
||||
set -ex
|
||||
${fourmolu}/bin/fourmolu -i `${pkgs.fd}/bin/fd -g *.hs src app`
|
||||
'';
|
||||
});
|
||||
|
||||
# --- Flake Local Nix Configuration ----------------------------
|
||||
nixConfig = {
|
||||
# This sets the flake to use the IOG nix cache.
|
||||
# Nix should ask for permission before using it,
|
||||
# but remove it here if you do not want it to.
|
||||
extra-substituters = ["https://cache.iog.io"];
|
||||
extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="];
|
||||
allow-import-from-derivation = "true";
|
||||
};
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
indentation: 2
|
||||
comma-style: leading
|
||||
record-brace-space: true
|
||||
indent-wheres: true
|
||||
diff-friendly-import-export: true
|
||||
respectful: true
|
||||
haddock-style: multi-line
|
||||
newlines-between-decls: 1
|
@ -0,0 +1,17 @@
|
||||
{pkgs, ...}: {
|
||||
# name = "project-name";
|
||||
compiler-nix-name = "ghc926"; # Version of GHC to use
|
||||
|
||||
# Cross compilation support:
|
||||
# crossPlatforms = p: pkgs.lib.optionals pkgs.stdenv.hostPlatform.isx86_64 ([
|
||||
# p.mingwW64
|
||||
# p.ghcjs
|
||||
# ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
||||
# p.musl64
|
||||
# ]);
|
||||
|
||||
# Tools to include in the development shell
|
||||
shell.tools.cabal = "latest";
|
||||
shell.tools.fourmolu = "latest";
|
||||
shell.tools.haskell-language-server = "latest";
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
cabal-version: 3.0
|
||||
name: servant-misskey
|
||||
version: 0.1.0
|
||||
|
||||
common c
|
||||
default-language:
|
||||
GHC2021
|
||||
default-extensions:
|
||||
BangPatterns
|
||||
BinaryLiterals
|
||||
BlockArguments
|
||||
ConstraintKinds
|
||||
DataKinds
|
||||
DeriveFunctor
|
||||
DeriveGeneric
|
||||
DeriveTraversable
|
||||
DerivingStrategies
|
||||
DerivingVia
|
||||
DuplicateRecordFields
|
||||
EmptyCase
|
||||
FlexibleContexts
|
||||
FlexibleInstances
|
||||
GADTs
|
||||
GeneralizedNewtypeDeriving
|
||||
HexFloatLiterals
|
||||
InstanceSigs
|
||||
ImportQualifiedPost
|
||||
KindSignatures
|
||||
LambdaCase
|
||||
MultiParamTypeClasses
|
||||
NoFieldSelectors
|
||||
NumericUnderscores
|
||||
OverloadedStrings
|
||||
ScopedTypeVariables
|
||||
StandaloneDeriving
|
||||
Strict
|
||||
TupleSections
|
||||
TypeApplications
|
||||
TypeOperators
|
||||
TypeSynonymInstances
|
||||
UndecidableInstances
|
||||
ghc-options:
|
||||
-Wall
|
||||
-Wcompat
|
||||
-Wincomplete-uni-patterns
|
||||
-Wincomplete-record-updates
|
||||
-Wredundant-constraints
|
||||
-Wmissing-deriving-strategies
|
||||
-Wno-duplicate-exports
|
||||
-- -Werror
|
||||
mixins:
|
||||
, base hiding (Prelude)
|
||||
, relude (Relude as Prelude)
|
||||
, relude
|
||||
|
||||
library
|
||||
import: c
|
||||
hs-source-dirs: src
|
||||
build-depends:
|
||||
, aeson
|
||||
, base
|
||||
, generically
|
||||
, relude
|
||||
, servant
|
||||
exposed-modules:
|
||||
Servant.Misskey
|
||||
Servant.Misskey.ActivityPub
|
||||
Servant.Misskey.Notes
|
||||
Servant.Misskey.Self
|
||||
Servant.Misskey.Users
|
||||
Servant.Misskey.Common
|
||||
|
||||
executable try
|
||||
import: c
|
||||
hs-source-dirs: app
|
||||
main-is: Main.hs
|
||||
build-depends:
|
||||
, aeson
|
||||
, base
|
||||
, generically
|
||||
, http-client-tls
|
||||
, relude
|
||||
, servant
|
||||
, servant-client
|
||||
, servant-misskey
|
@ -0,0 +1,9 @@
|
||||
module Servant.Misskey (Api) where
|
||||
|
||||
import Servant.API ((:<|>), (:>))
|
||||
import Servant.Misskey.ActivityPub qualified as ActivityPub
|
||||
import Servant.Misskey.Notes qualified as Notes
|
||||
import Servant.Misskey.Self qualified as Self
|
||||
import Servant.Misskey.Users qualified as Users
|
||||
|
||||
type Api = "api" :> (ActivityPub.Api :<|> Self.Api :<|> Notes.Api :<|> Users.Api)
|
@ -0,0 +1,27 @@
|
||||
module Servant.Misskey.ActivityPub (Api, ApiGet, ApiShow, ApGetResponse, ApShowResponse (ApShowResponseNote, ApShowResponseUser)) where
|
||||
|
||||
import Data.Aeson (FromJSON (parseJSON), Options (constructorTagModifier, sumEncoding), SumEncoding (TaggedObject, contentsFieldName, tagFieldName), genericParseJSON)
|
||||
import Data.Aeson qualified as Aeson (Object)
|
||||
import Data.List (stripPrefix)
|
||||
import Data.Maybe (fromJust)
|
||||
import Servant.API (JSON, Post, ReqBody, (:<|>), (:>))
|
||||
import Servant.Misskey.Common (Authenticated, Note, UriRequest, UserDetailed, defaultJSONOptions)
|
||||
|
||||
type Api = "ap" :> (ApiGet :<|> ApiShow)
|
||||
type ApiGet = "get" :> ReqBody '[JSON] (Authenticated UriRequest) :> Post '[JSON] ApGetResponse
|
||||
type ApiShow = "show" :> ReqBody '[JSON] (Authenticated UriRequest) :> Post '[JSON] ApShowResponse
|
||||
|
||||
type ApGetResponse = Aeson.Object
|
||||
|
||||
data ApShowResponse
|
||||
= ApShowResponseNote Note
|
||||
| ApShowResponseUser UserDetailed
|
||||
deriving stock (Generic, Show)
|
||||
|
||||
instance FromJSON ApShowResponse where
|
||||
parseJSON =
|
||||
genericParseJSON
|
||||
defaultJSONOptions
|
||||
{ sumEncoding = TaggedObject {tagFieldName = "type", contentsFieldName = "object"}
|
||||
, constructorTagModifier = fromJust . stripPrefix "ApShowResponse"
|
||||
}
|
@ -0,0 +1,221 @@
|
||||
module Servant.Misskey.Common where
|
||||
|
||||
import Data.Aeson (FromJSON (parseJSON), Options (constructorTagModifier, fieldLabelModifier, omitNothingFields), ToJSON (toJSON), genericParseJSON, genericToJSON, (.:))
|
||||
import Data.Aeson qualified as Aeson (Object, Value (Null, Object, String), defaultOptions, withObject)
|
||||
import Data.Aeson.KeyMap qualified as Aeson.KeyMap (insert, singleton)
|
||||
import Data.Char qualified as Char (toLower)
|
||||
import Data.List (dropWhileEnd, stripPrefix)
|
||||
import Data.Maybe (fromJust)
|
||||
import GHC.Generics.Generically (Generically (Generically))
|
||||
|
||||
defaultJSONOptions :: Options
|
||||
defaultJSONOptions = Aeson.defaultOptions {omitNothingFields = True}
|
||||
|
||||
data Authenticated a = Authenticated {token :: Text, inner :: a}
|
||||
|
||||
instance ToJSON a => ToJSON (Authenticated a) where
|
||||
toJSON Authenticated {token, inner} = case toJSON inner of
|
||||
Aeson.Object o -> Aeson.Object $! Aeson.KeyMap.insert "i" (Aeson.String token) o
|
||||
Aeson.Null -> Aeson.Object $! Aeson.KeyMap.singleton "i" $! Aeson.String token
|
||||
other -> error $! "ToJSON (Authenticated a).toJSON: toJSON inner didn't return Aeson.Object: " <> show other
|
||||
|
||||
data NonExhaustive a = Known a | Unknown Aeson.Value
|
||||
deriving stock (Show)
|
||||
|
||||
instance FromJSON a => FromJSON (NonExhaustive a) where
|
||||
parseJSON j = Known <$> parseJSON j <|> pure (Unknown j)
|
||||
|
||||
newtype Id = Id Text
|
||||
deriving newtype (Show, FromJSON, ToJSON)
|
||||
|
||||
newtype UriRequest = UriRequest {uri :: Text}
|
||||
deriving stock (Generic, Show)
|
||||
|
||||
deriving via Generically UriRequest instance ToJSON UriRequest
|
||||
|
||||
data Note = Note
|
||||
{ id :: NoteId
|
||||
, createdAt :: Text
|
||||
, text :: Maybe Text
|
||||
, cw :: Maybe Text
|
||||
, user :: User
|
||||
, userId :: UserId
|
||||
, reply :: Maybe Note
|
||||
, replyId :: Maybe NoteId
|
||||
, renote :: Maybe Note
|
||||
, renoteId :: Maybe NoteId
|
||||
, visibility :: NoteVisibility
|
||||
, myReaction :: Maybe Text
|
||||
, reactions :: Map Text Integer
|
||||
, renoteCount :: Integer
|
||||
, repliesCount :: Integer
|
||||
-- , poll :: Maybe Poll
|
||||
}
|
||||
deriving stock (Generic, Show)
|
||||
|
||||
deriving via Generically Note instance FromJSON Note
|
||||
|
||||
data NoteVisibility
|
||||
= VisibilityPublic
|
||||
| VisibilityHome
|
||||
| VisibilityFollowers
|
||||
| VisibilitySpecified
|
||||
deriving stock (Generic, Show)
|
||||
|
||||
instance FromJSON NoteVisibility where
|
||||
parseJSON = genericParseJSON defaultJSONOptions {constructorTagModifier = fmap Char.toLower . fromJust . stripPrefix "Visibility"}
|
||||
|
||||
newtype NoteId = NoteId Id
|
||||
deriving newtype (Show, FromJSON, ToJSON)
|
||||
|
||||
type User = UserLite
|
||||
|
||||
type UserDetailed = UserLite
|
||||
|
||||
data UserLite = UserLite
|
||||
{ id :: UserId
|
||||
, username :: Text
|
||||
, host :: Maybe Text
|
||||
, name :: Text
|
||||
, onlineStatus :: OnlineStatus
|
||||
, avatarUrl :: Text
|
||||
, avatarBlurhash :: Text
|
||||
, emojis :: Map Text Text -- Map EmojiName Url
|
||||
, instance_ :: Maybe Aeson.Object
|
||||
{-
|
||||
name: Instance['name'];
|
||||
softwareName: Instance['softwareName'];
|
||||
softwareVersion: Instance['softwareVersion'];
|
||||
iconUrl: Instance['iconUrl'];
|
||||
faviconUrl: Instance['faviconUrl'];
|
||||
themeColor: Instance['themeColor'];
|
||||
-}
|
||||
}
|
||||
deriving stock (Generic, Show)
|
||||
|
||||
userLiteJsonOptions :: Options
|
||||
userLiteJsonOptions = defaultJSONOptions {fieldLabelModifier = dropWhileEnd (== '_')}
|
||||
|
||||
instance FromJSON UserLite where
|
||||
parseJSON = genericParseJSON userLiteJsonOptions
|
||||
|
||||
instance ToJSON UserLite where
|
||||
toJSON = genericToJSON userLiteJsonOptions
|
||||
|
||||
newtype UserId = UserId Id
|
||||
deriving newtype (Show, FromJSON, ToJSON)
|
||||
|
||||
data OnlineStatus = StatusOnline | StatusActive | StatusOffline | StatusUnknown
|
||||
deriving stock (Generic, Show)
|
||||
|
||||
onlineStatusJsonOptions :: Options
|
||||
onlineStatusJsonOptions = defaultJSONOptions {constructorTagModifier = fmap Char.toLower . fromJust . stripPrefix "Status"}
|
||||
|
||||
instance FromJSON OnlineStatus where
|
||||
parseJSON = genericParseJSON onlineStatusJsonOptions
|
||||
|
||||
instance ToJSON OnlineStatus where
|
||||
toJSON = genericToJSON onlineStatusJsonOptions
|
||||
|
||||
data Notification = Notification
|
||||
{ id :: NotificationId
|
||||
, createdAt :: Text
|
||||
, isRead :: Bool
|
||||
, variant :: NonExhaustive NotificationVariant
|
||||
}
|
||||
deriving stock (Show)
|
||||
|
||||
instance FromJSON Notification where
|
||||
parseJSON = Aeson.withObject "Notification" \o ->
|
||||
Notification
|
||||
<$> o .: "id"
|
||||
<*> o .: "createdAt"
|
||||
<*> o .: "isRead"
|
||||
<*> parseJSON (Aeson.Object o)
|
||||
|
||||
data NotificationVariant
|
||||
= NotificationReaction
|
||||
{ reaction :: Text
|
||||
, user :: User
|
||||
, userId :: UserId
|
||||
, note :: Note
|
||||
}
|
||||
| NotificationNote
|
||||
{ noteVariant :: NotificationNoteVariant
|
||||
, user :: User
|
||||
, userId :: UserId
|
||||
, note :: Note
|
||||
}
|
||||
| NotificationFollow
|
||||
{ followVariant :: NotificationFollowVariant
|
||||
, user :: User
|
||||
, userId :: UserId
|
||||
}
|
||||
deriving stock (Show)
|
||||
|
||||
instance FromJSON NotificationVariant where
|
||||
parseJSON = Aeson.withObject "NotificationVariant" \o ->
|
||||
o .: "type" >>= \case
|
||||
"reaction" ->
|
||||
NotificationReaction
|
||||
<$> o .: "reaction"
|
||||
<*> o .: "user"
|
||||
<*> o .: "userId"
|
||||
<*> o .: "note"
|
||||
"reply" ->
|
||||
NotificationNote NotificationNoteReply
|
||||
<$> o .: "user"
|
||||
<*> o .: "userId"
|
||||
<*> o .: "note"
|
||||
"renote" ->
|
||||
NotificationNote NotificationNoteRenote
|
||||
<$> o .: "user"
|
||||
<*> o .: "userId"
|
||||
<*> o .: "note"
|
||||
"quote" ->
|
||||
NotificationNote NotificationNoteQuote
|
||||
<$> o .: "user"
|
||||
<*> o .: "userId"
|
||||
<*> o .: "note"
|
||||
"mention" ->
|
||||
NotificationNote NotificationNoteMention
|
||||
<$> o .: "user"
|
||||
<*> o .: "userId"
|
||||
<*> o .: "note"
|
||||
"pollVote" ->
|
||||
NotificationNote NotificationNotePollVote
|
||||
<$> o .: "user"
|
||||
<*> o .: "userId"
|
||||
<*> o .: "note"
|
||||
"follow" ->
|
||||
NotificationFollow NotificationFollowFollow
|
||||
<$> o .: "user"
|
||||
<*> o .: "userId"
|
||||
"followRequestAccepted" ->
|
||||
NotificationFollow NotificationFollowRequestAccepted
|
||||
<$> o .: "user"
|
||||
<*> o .: "userId"
|
||||
"receiveFollowRequest" ->
|
||||
NotificationFollow NotificationFollowReceiveRequest
|
||||
<$> o .: "user"
|
||||
<*> o .: "userId"
|
||||
other -> fail $! "Unknown type " <> other
|
||||
|
||||
data NotificationNoteVariant
|
||||
= NotificationNoteReply
|
||||
| NotificationNoteRenote
|
||||
| NotificationNoteQuote
|
||||
| NotificationNoteMention
|
||||
| NotificationNotePollVote
|
||||
deriving stock (Show)
|
||||
|
||||
data NotificationFollowVariant
|
||||
= NotificationFollowFollow
|
||||
| NotificationFollowRequestAccepted
|
||||
| NotificationFollowReceiveRequest
|
||||
deriving stock (Show)
|
||||
|
||||
newtype NotificationId = NotificationId Id
|
||||
deriving newtype (Show, FromJSON, ToJSON)
|
||||
|
||||
type NotificationType = Text
|
@ -0,0 +1,35 @@
|
||||
module Servant.Misskey.Notes (Api, ApiTimeline, NotesTimelineRequest (NotesTimelineRequest, limit, sinceId, untilId, sinceDate, untilDate), defaultNotesTimelineRequest) where
|
||||
|
||||
import Data.Aeson (ToJSON (toJSON), genericToJSON)
|
||||
import Servant.API (JSON, Post, ReqBody, (:>))
|
||||
import Servant.Misskey.Common (
|
||||
Authenticated,
|
||||
Note,
|
||||
NoteId,
|
||||
defaultJSONOptions,
|
||||
)
|
||||
|
||||
type Api = "notes" :> ApiTimeline
|
||||
type ApiTimeline = "timeline" :> ReqBody '[JSON] (Authenticated NotesTimelineRequest) :> Post '[JSON] [Note]
|
||||
|
||||
data NotesTimelineRequest = NotesTimelineRequest
|
||||
{ limit :: Maybe Integer
|
||||
, sinceId :: Maybe NoteId
|
||||
, untilId :: Maybe NoteId
|
||||
, sinceDate :: Maybe Integer
|
||||
, untilDate :: Maybe Integer
|
||||
}
|
||||
deriving stock (Generic, Show)
|
||||
|
||||
defaultNotesTimelineRequest :: NotesTimelineRequest
|
||||
defaultNotesTimelineRequest =
|
||||
NotesTimelineRequest
|
||||
{ limit = Nothing
|
||||
, sinceId = Nothing
|
||||
, untilId = Nothing
|
||||
, sinceDate = Nothing
|
||||
, untilDate = Nothing
|
||||
}
|
||||
|
||||
instance ToJSON NotesTimelineRequest where
|
||||
toJSON = genericToJSON defaultJSONOptions
|
@ -0,0 +1,48 @@
|
||||
module Servant.Misskey.Self (
|
||||
Api,
|
||||
ApiSelf,
|
||||
ApiNotifications,
|
||||
SelfNotificationsRequest (SelfNotificationsRequest, limit, sinceId, untilId, following, markAsRead, includeTypes, excludeTypes),
|
||||
defaultSelfNotificationsRequest,
|
||||
) where
|
||||
|
||||
import Data.Aeson (ToJSON (toJSON), genericToJSON)
|
||||
import Servant.API (JSON, Post, ReqBody, (:<|>), (:>))
|
||||
import Servant.Misskey.Common (
|
||||
Authenticated,
|
||||
Notification,
|
||||
NotificationId,
|
||||
NotificationType,
|
||||
User,
|
||||
defaultJSONOptions,
|
||||
)
|
||||
|
||||
type Api = "i" :> (ApiSelf :<|> ApiNotifications)
|
||||
type ApiSelf = ReqBody '[JSON] (Authenticated (Proxy ())) :> Post '[JSON] User
|
||||
type ApiNotifications = "notifications" :> ReqBody '[JSON] (Authenticated SelfNotificationsRequest) :> Post '[JSON] [Notification]
|
||||
|
||||
data SelfNotificationsRequest = SelfNotificationsRequest
|
||||
{ limit :: Maybe Integer
|
||||
, sinceId :: Maybe NotificationId
|
||||
, untilId :: Maybe NotificationId
|
||||
, following :: Maybe Bool
|
||||
, markAsRead :: Maybe Bool
|
||||
, includeTypes :: Maybe [NotificationType]
|
||||
, excludeTypes :: Maybe [NotificationType]
|
||||
}
|
||||
deriving stock (Generic)
|
||||
|
||||
defaultSelfNotificationsRequest :: SelfNotificationsRequest
|
||||
defaultSelfNotificationsRequest =
|
||||
SelfNotificationsRequest
|
||||
{ limit = Nothing
|
||||
, sinceId = Nothing
|
||||
, untilId = Nothing
|
||||
, following = Nothing
|
||||
, markAsRead = Nothing
|
||||
, includeTypes = Nothing
|
||||
, excludeTypes = Nothing
|
||||
}
|
||||
|
||||
instance ToJSON SelfNotificationsRequest where
|
||||
toJSON = genericToJSON defaultJSONOptions
|
@ -0,0 +1,16 @@
|
||||
module Servant.Misskey.Users (Api, ApiShow, UsersShowRequest (UsersShowById, UsersShowByUsername, userId, username, host)) where
|
||||
|
||||
import Data.Aeson (Options (sumEncoding), SumEncoding (UntaggedValue), ToJSON (toJSON), genericToJSON)
|
||||
import Servant.API (JSON, Post, ReqBody, (:>))
|
||||
import Servant.Misskey.Common (UserDetailed, UserId, defaultJSONOptions)
|
||||
|
||||
type Api = "users" :> ApiShow
|
||||
type ApiShow = "show" :> ReqBody '[JSON] UsersShowRequest :> Post '[JSON] UserDetailed
|
||||
|
||||
data UsersShowRequest
|
||||
= UsersShowById {userId :: UserId}
|
||||
| UsersShowByUsername {username :: Text, host :: Maybe Text}
|
||||
deriving stock (Generic, Show)
|
||||
|
||||
instance ToJSON UsersShowRequest where
|
||||
toJSON = genericToJSON defaultJSONOptions {sumEncoding = UntaggedValue}
|
Loading…
Reference in new issue