Metadata-Version: 2.4
Name: ics-importer
Version: 0.1.0
Summary: An internal tool to import calendar files from ICS format in emails.
Author-email: Jiayu Hu <jiayu.hu@inkbridge.io>
Project-URL: Homepage, https://github.com/InkbridgeNetworks/calendar-filters/tree/main/ics_importer
Requires-Python: >=3.0
Description-Content-Type: text/markdown
Requires-Dist: caldav>=2.0.1
Requires-Dist: icalendar>=6.3.1
Requires-Dist: ldap3>=2.9.1
Requires-Dist: niquests>=3.14.1
Requires-Dist: PyYAML>=6.0.2
Requires-Dist: Radicale>=3.5.4

# ICS Importer

## Development

1. Activate a virtual environment

    ```bash
    python3 -m venv venv
    source venv/bin/activate
    ```

2. Install dependencies: `pip install -r requirement.txt`

## Deployment

1. Activate an venv:

    ```bash
    python3 -m venv venv
    source venv/bin/activate
    ```

2. Install `ics-importer` package from PyPI by running `pip install --extra-index-url https://pypi.inkbridge.io ics-importer`

3. Copy the `config.yaml` to the default path `/etc/postfix/ics-importer/config.yaml`, or any other destination.

4. Change the permissions for the `ics-importer` and `/etc/postfix/ics-importer/config.yaml` to being readable by the user that run the filter (e.g. userA).

5. Create symlink for the Python binary: `sudo ln -s <sogo_filter_package_dir>/venv/bin/ics-importer /usr/local/bin/ics-importer`

6. Configure Postfix

    Create `/etc/postfix/header_checks` with content:

    ```text
        /^(Content-(Type|Disposition):.*(text\/calendar|application\/ics|\.ics|\.ical))/ FILTER ics-importer:dummy
    ```

    In `/etc/postfix/main.cf` add:

    ```text
        header_checks = regexp:/etc/postfix/header_checks
    ```

    if using `regexp`

    or

    ```text
        header_checks = pcre:/etc/postfix/header_checks
    ```

    if using `pcre` for the header_checks.

    In `/etc/postfix/master.cf` add:

    ```text
        ics-importer unix -       n       n       -       -       pipe
            user=userA argv=/usr/local/bin/ics-importer
    ```

    If the config path is not in `/etc/postfix/ics-importer/config.yaml`, pass in argument `--config <cofnig_path>` to the pipe command as well.

    Then reload Postfix `sudo postfix reload`.
