Adding Mobilizon (events) as a source: multiple potential fields for the same attribute ?
First of all, thank you for this extension !
We met a few days back and as I told you I'd like to add Mobilizon as a kind of source, which should hopefully convince more people to use Mobilizon. Discoverability is, to me, the biggest problem of the decentralized web and I feel like Meta-press.es can be hacked to tackle this problem.
Mobilizon is using GraphQL for its API. This means POSTing a body with a specific structure, and the reply is a JSON.
Here's the blurb in the request:
{"query":"query SearchEventsAndGroups($location: String, $radius: Float, $tags: String, $term: String, $type: EventType, $category: String, $beginsOn: DateTime, $endsOn: DateTime, $eventPage: Int, $limit: Int) {\n searchEvents(location: $location, radius: $radius, tags: $tags, term: $term, type: $type, category: $category, beginsOn: $beginsOn, endsOn: $endsOn, page: $eventPage, limit: $limit) {\n total\n elements {\n title\n url\n beginsOn\n attributedTo {\n name\n }\n organizerActor {\n name\n }\n }\n }\n}\n","variables":{"term":"concert"},"operationName":"SearchEventsAndGroups"}
Basically, a JSON object with a query
field and variables
. The query looks like this when formatted:
query SearchEventsAndGroups($location: String, $radius: Float, $tags: String, $term: String, $type: EventType, $category: String, $beginsOn: DateTime, $endsOn: DateTime, $eventPage: Int, $limit: Int) {
searchEvents(location: $location, radius: $radius, tags: $tags, term: $term, type: $type, category: $category, beginsOn: $beginsOn, endsOn: $endsOn, page: $eventPage, limit: $limit) {
total
elements {
title
url
beginsOn
attributedTo {
name
}
organizerActor {
name
}
}
}
}
(Note: this is not the query used by the actual frontend, which is waaaaaay more complicated. It includes stuff like location, events options etc that might not be relevant for Meta-Press.es)
The reply is a standard JSON:
{
"data": {
"searchEvents": {
"elements": [
{
"attributedTo": null,
"beginsOn": "2022-05-01T19:00:00Z",
"organizerActor": {
"name": "VERO JEAN-LUC"
},
"title": "CONCERTS A VENIR ...",
"url": "https://mobilizon.fr/events/80c84e36-2155-4fa2-a67f-e900ea49cc86"
},
{
"attributedTo": null,
"beginsOn": "2022-10-01T12:00:00Z",
"organizerActor": {
"name": "Alternatiba Rennes"
},
"title": "Weekend des possibles 2022",
"url": "https://mobilizon.fr/events/a114010e-bce1-4547-86e2-d5b230c3c7ed"
},
{
"attributedTo": null,
"beginsOn": "2022-10-01T18:00:00Z",
"organizerActor": {
"name": "Still Freak"
},
"title": "Rudeboy plays Urban Dance Squad en concert @ l'Accordeur",
"url": "https://mobilizon.fr/events/10c25817-3f25-4edc-be04-4293addf77ac"
},
{
"attributedTo": {
"name": "Musique sur Nantes ! :D"
},
"beginsOn": "2022-10-05T17:30:00Z",
"organizerActor": null,
"title": "SCENE OUVERTE MUSICALE au Chat Noir",
"url": "https://mobilizon.fr/events/c11c3a8a-bc32-450d-b33c-ee385eb866ba"
},
{
"attributedTo": null,
"beginsOn": "2022-10-06T16:00:00Z",
"organizerActor": {
"name": "Still Freak"
},
"title": "Cult of Luna + Caspian + Birds In Row ~ Atabal Biarritz",
"url": "https://mobilizon.fr/events/4cc2afc6-7fbb-4b39-ba8b-5770f4130816"
},
{
"attributedTo": null,
"beginsOn": "2022-10-06T16:15:00Z",
"organizerActor": {
"name": "Still Freak"
},
"title": "PUNISH YOURSELF à Toulouse - Pink Paradize 2022",
"url": "https://mobilizon.fr/events/46f6b32a-0597-4c0d-8f56-96d418e172ed"
},
{
"attributedTo": null,
"beginsOn": "2022-10-07T18:45:00Z",
"organizerActor": {
"name": "Will pandarec"
},
"title": "LUNCH + CHEAP ENTERTAINMENT @ [L'INTERMEDIAIRE]",
"url": "https://mobilizon.fr/events/49073407-9c68-4569-98e7-94bf11bbe032"
},
{
"attributedTo": {
"name": "le Plancher des Chèvres"
},
"beginsOn": "2022-10-08T17:30:00Z",
"organizerActor": null,
"title": "OTTILIE [B] COEUR <3 et LOUISE O'SMAN",
"url": "https://mobilizon.fr/events/d03eefd7-368c-457c-9ae1-b0d0cb87b465"
},
{
"attributedTo": {
"name": "Apéros-Discussions SENSIBILIZON Nantes"
},
"beginsOn": "2022-10-22T15:00:00Z",
"organizerActor": null,
"title": "DROITS HUMAINS : ON EN EST OÙ ? Samedi 22/10, 17h-19h",
"url": "https://mobilizon.fr/events/56a8307b-f4e6-439a-a7a7-027b2e429e42"
},
{
"attributedTo": null,
"beginsOn": "2022-10-29T17:30:00Z",
"organizerActor": {
"name": "Still Freak"
},
"title": "Goulamas’K - Resaka Sonora",
"url": "https://mobilizon.fr/events/37f991f8-2b4b-4e10-9362-b72210682064"
}
],
"total": 12
}
}
}
To play with the API, here's a very helpful link targeting the main instance directly: https://mobilizon.fr/graphiql
So, it seems to be pretty straightforward, but there's an issue: as you can see we need to include both organizerActor
and attributedTo
because sometimes one is null and we must use the other. Hence the question: is it possible to indicate two fields and take the first one that is not null ?