Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HackITM ActivityPub Fediverse Experimente
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Hubel
HackITM ActivityPub Fediverse Experimente
Compare revisions
d90ee51da6ca8ea899d559e788af4ed0f8d30d6c to 3ff052812021e850e94c0857c40a946a768bb18b
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
Andreas.Hubel/hackitm-activity-pub
Select target project
No results found
3ff052812021e850e94c0857c40a946a768bb18b
Select Git revision
Branches
main
Swap
Target
Andreas.Hubel/hackitm-activity-pub
Select target project
Andreas.Hubel/hackitm-activity-pub
1 result
d90ee51da6ca8ea899d559e788af4ed0f8d30d6c
Select Git revision
Branches
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
fix issue
· 9b9314a7
Benedikt Hermann
authored
2 months ago
9b9314a7
add outbox route + pagination
· 3ff05281
Benedikt Hermann
authored
2 months ago
3ff05281
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/server.ts
+44
-3
44 additions, 3 deletions
src/server.ts
with
44 additions
and
3 deletions
src/server.ts
View file @
3ff05281
...
...
@@ -7,6 +7,8 @@ import { transformEpisode, transformEpisodeList } from './mappings';
const
app
=
express
();
const
PORT
=
3000
;
const
root
=
"
https://social.audiothek.de/@blaue-couch
"
const
audiothekApi
=
new
Client
({
url
:
'
https://api.ardaudiothek.de/graphql
'
,
...
...
@@ -66,7 +68,7 @@ async function fetchData<R>(query: any, variables: any) {
async
function
main
()
{
const
response
=
await
fetchData
(
query
,
{
id
:
'
14278953
'
});
const
response
=
await
fetchData
<
EpisodeResponse
>
(
query
,
{
id
:
'
14278953
'
});
if
(
response
)
{
const
activityPubEpisode
=
transformEpisode
(
response
);
...
...
@@ -96,6 +98,8 @@ app.get('/:actor/episodes/:id', async (req, res) => {
});
app
.
get
(
'
/:actor/episodes
'
,
async
(
req
,
res
)
=>
{
const
offset
=
10
*
((
+
req
.
query
.
page
!
||
1
)
-
1
);
const
query
=
gql
`
query ShowWithEpisodes($showId: ID!, $first: Int = 10, $offset: Int) {
show(id: $showId) {
...
...
@@ -134,7 +138,7 @@ app.get('/:actor/episodes', async (req, res) => {
// TODO: verifiy that the actor is the same as the attributedTo field
const
data
=
await
fetchData
<
any
>
(
query
,
{
showId
:
"
urn:ard:show:a42d1ea0b4a07053
"
});
const
data
=
await
fetchData
<
any
>
(
query
,
{
showId
:
"
urn:ard:show:a42d1ea0b4a07053
"
,
offset
});
if
(
!
data
)
{
res
.
status
(
404
).
json
({
error
:
'
Episode not found
'
});
return
;
...
...
@@ -148,8 +152,45 @@ app.get('/:actor/episodes', async (req, res) => {
}
});
app
.
get
(
'
/:actor/outbox
'
,
async
(
req
,
res
)
=>
{
const
query
=
gql
`
query ShowEpisodeTotal($showId: ID!) {
show(id: $showId) {
coreId
externalId
title
url
items(condition: { isPublished: true }) {
totalCount
}
}
}`
;
const
data
=
await
fetchData
<
any
>
(
query
,
{
showId
:
"
urn:ard:show:a42d1ea0b4a07053
"
});
if
(
!
data
)
{
res
.
status
(
404
).
json
({
error
:
'
Show not found
'
});
return
;
}
const
{
totalCount
}
=
data
.
show
.
items
;
res
.
json
({
"
@context
"
:
"
https://www.w3.org/ns/activitystreams
"
,
"
id
"
:
`
${
root
}
/outbox`
,
"
type
"
:
"
OrderedCollection
"
,
"
to
"
:
[
"
https://www.w3.org/ns/activitystreams#Public
"
],
"
totalItems
"
:
totalCount
,
"
first
"
:
`
${
root
}
/episodes?page=1`
,
"
current
"
:
`
${
root
}
/outbox`
,
"
last
"
:
`
${
root
}
/episodes?page=
${
Math
.
floor
(
totalCount
/
10
)}
`
});
});
app
.
get
(
'
/
@blaue-couch
'
,
async
(
req
,
res
)
=>
{
app
.
get
(
'
/
:actor
'
,
async
(
req
,
res
)
=>
{
res
.
json
({
"
@context
"
:
"
https://www.w3.org/ns/activitystreams
"
,
"
id
"
:
"
urn:ard:show:a42d1ea0b4a07053
"
,
...
...
This diff is collapsed.
Click to expand it.