Go to file
André 52c17f25fd add dependencies to pip 2023-06-15 10:15:04 +02:00
src fix tib for events without image 2023-06-15 10:14:11 +02:00
.gitignore add logratation folder 2023-03-18 17:50:31 +01:00
.hugo_build.lock
LICENSE
README.md add dependencies to pip 2023-06-15 10:15:04 +02:00
config-example.yaml
schema.graphql

README.md

Mobilizon Automation

Background

This software was written to help our Mobilizon instance at https://events.graz.social getting started via crossposting events from some famous event organizers in Graz. Though this does not support the idea of a federated internet directly it seems to be a necessary bridging technology, in the truest sense of the word.

It fetches the events from the organizers websites, it is not intended to do so via facebook or any other centralistic source.

Usage

  1. Create a new Mobilizon account and person/actor.

  2. Create the Mobilizon groups you want to bridge the events to.

  3. Add your actor to all the groups with at least moderator privileges.

  4. Copy the config-example.yaml to config.yaml and adjust it according to your needs.

---
endpoint: https://{your.mobilizon}/api
email: {your_actor@its.email}
organizers:
  - name: theaterface
    group: remote_mobilizon_groupname1
  - name: cafe_wolf
    group: remote_mobilizon_groupname1
  1. Install python dependencies (virtual environment recommended):
pip install gql graphql-core beautifulsoup4 urllib3 pytz PyYAML PYJWT icalevents aiohttp requests ics xmltodict
  1. Setup a cronjob (e.g. hourly) to run python src/crossposter.py periodically.

Adding new organizers

It should be quite easy to add a new organizer by yourself.

  • Create a new file called {organizername}.py inside src/organizers/.

  • This python file/module must contain at least a class named Organizer.

  • The class Organizer must contain one function called getEventList, which return a list of events, see the details below.

from utils import Event

class Organizer:
    """
    https://{website_of_organizer}
    """
    def getEventList(self):
        """
        Returns list with upcoming events from {organizer}
        """
        events = []

        ...

        # You might do this a few times:
        events.append(
            Event(
                # The unique identifier for this event. This could be
                #  - the start-datetime
                #  - some known id from the organizers website
                #  - or anything else unique to to organizer.
                # It must be a string.
                identifier=identifier,
                # Explained below in detail.
                params=params,
                # String. The remote URL of the header image of the event.
                image_url=image_url,
                # String. The headers image alt text, optional.
                image_alt=image_alt
        )

        return events

The paramter params must be a python dictionary with the events infos. It exactly follows the Event object as defined the schema.graphql of Mobilizon. If it does not fit the bridging will fail.

params = {
    # Mandatory #
    #############
    # String
    "title": "Some title",
    # String
    "description": "This is some description in <h3>html</h3>",
    # Datetime in ISO format with UTC offset.
    "beginsOn": "2022-12-24T20:00:00+00:00",

    # Optional #
    ############
    # Datetime in ISO format with UTC offset.
    "endsOn": "2022-12-24T20:00:00+00:00",
    # Category Enum, see EventCategory in the schema.graphql
    "category": "MUSIC",
    # The online site for this specific event.
    "onlineAddress": "https://someorganizer/event/1",
    # The physical address
    "physicalAddress": {
        "street": "Somestreet 11",
        "postalCode": "8010",
        "locality": "Graz",
        "description": "Awesome Location"
    }
}

Testing (new organizers)

We recommend setting up a test-instance locally on your machine via docker:

Get the docker-compose repository

git clone https://framagit.org/framasoft/joinmobilizon/docker.git docker-mobilizon
cd docker-mobilizon

Update the env file

cp env.template .env

Edit the .env content with your own settings. You mainly need to edit the host to localhost. O

We recommend to even use a custom domain like mysite.example, add it to your /etc/hosts file, so it points to 127.0.0.1, make a fake https certificate via mkcert, and use a reverse proxy like nginx, to setup this testing Mobilizon via locally-trusted https.

Start the container

docker-compose up -d

Setup a briding user for testing and create the groups for the organizers.

docker-compose exec mobilizon mobilizon_ctl users.new "your@email.com" --admin --password "your_silly_passw0rd"
docker-compose exec mobilizon mobilizon_ctl actors.new  --email "your@email.com" --display-name "Testuser" --username "testuser"
docker-compose exec mobilizon mobilizon_ctl actors.new --username "forum_stadtpark" --display-name 'ForumStadtpark' --group-admin "testuser" --type "group"
docker-compose exec mobilizon mobilizon_ctl actors.new --username "cafe_wolf" --display-name 'CaféWolf' --group-admin "testuser" --type "group"
docker-compose exec mobilizon mobilizon_ctl actors.new --username "theatercafe" --display-name 'Theatercafé' --group-admin "testuser" --type "group"