Commit Graph

210 Commits

Author SHA1 Message Date
magowiz b04b0ba923 add initial configuration, replace get_configuration with toml.load to avoid validation error on aerich init 2021-12-04 18:24:09 +01:00
magowiz 653d98e076 add aerich configuration 2021-12-04 17:56:31 +01:00
magowiz 1f27f2f78c add aerich upgrade before init 2021-12-04 17:55:43 +01:00
magowiz 1195aef57e installed aerich 2021-12-04 14:40:34 +01:00
Giacomo Leidi c07c0ad30d cli: cli: Add some consistency to help messages. 2021-12-04 01:20:34 +01:00
Simone Robutti a6df8eb494
added badge 2021-12-03 17:57:06 +01:00
Giacomo Leidi 833a390839 cli: inspect: Make two subcommands for events and publications. 2021-12-03 00:06:51 +01:00
Giacomo Leidi 65ed092204 cli: cli: Add option shortcuts. 2021-12-03 00:04:36 +01:00
Giacomo Leidi 6f8f96d5b6 cli: inspect: Refactor command.
Now the inspect command can display informations about
different kind of objects including events and publications.

This patch also changes the cli to output columnar values
suitable for further processing with standard Unix
tool, such as awk.

$ mobilizon-reshare.sh inspect publication -s completed | awk '{ print  }' | sort | uniq -c
[2021-12-01 01:05:55,321] [20] [INFO] Tortoise-ORM shutdown
      2 mastodon
      2 telegram
      2 zulip
2021-12-01 01:13:59 +01:00
Giacomo Leidi 2d8855f6fe cli: inspect_event: Separate paged fields with \t. 2021-11-30 23:46:07 +01:00
Giacomo Leidi 2966e90d9d cli: cli: Add --version. 2021-11-30 23:45:01 +01:00
Giacomo Leidi 64c9d168c3 storage: publications_with_status: Return a list[Publication]. 2021-11-30 00:05:11 +01:00
Giacomo Leidi a079241801 Add pytest-cov dependency. 2021-11-28 17:27:12 +01:00
Giacomo Leidi fee794be48 test: puslishers: Adapt Zulip tests to HTTPResponseError. 2021-11-28 17:25:43 +01:00
Giacomo Leidi d6714f2142
publishers: zulip: Catch general HTTPErrors. (#107)
* publishers: zulip: Catch general HTTPErrors.
2021-11-28 16:50:22 +01:00
Giacomo Leidi 227ce22d57
scripts: Add mobilizon-reshare.sh. (#106)
* scripts: Add mobilizon-reshare.sh.

This script lets you run mobilizon-reshare commands from your git
checkout. This is very useful for debugging new features or in general
just to have a quick feedback loop from your modifications.

Example usage:

$ scripts/mobilizon-reshare.sh inspect all
2021-11-28 16:42:42 +01:00
Simone Robutti 49b79de38f
Merge pull request #108 from magowiz/feature/test_coverage
Feature/test coverage
2021-11-28 10:11:49 +01:00
magowiz 18e97c863d
change report format from html to term-missing 2021-11-27 23:35:30 +01:00
Giacomo Leidi f8bbd1df41
Fix publication exception handling for notification. (#105) 2021-11-27 23:31:44 +01:00
magowiz d60c5eabfb add pytest coverage configuration 2021-11-27 18:47:43 +01:00
Giacomo Leidi 1efa191771
Query refactoring (#102)
* Rename query modules.

* storage: save_publication_report: Create publications.

* Remove placeholder PublicationStatus.UNSAVED

* Minor fixes.
2021-11-24 23:58:06 +01:00
Giacomo Leidi ed8f752fe6
Make logs a little bit more informative. (#100) 2021-11-20 15:53:38 +01:00
Simone Robutti 2476686c33
added facebook publisher (#99)
* added facebook publisher

* mobilizon-reshare.git: [propagated-inputs]: Add python-sdk-facebook.

This package definition has been generated with `guix import pypi -r
facebook-sdk`.

* mobilizon-reshare.git: [propagated-inputs]: Use python-facebook-sdk.git.

Co-authored-by: Giacomo Leidi <goodoldpaul@autistici.org>
2021-11-20 15:40:10 +01:00
Giacomo Leidi a91e72c3ef mobilizon-reshare.git: Disable test_format_event.
These tests somehow depend on the system timezone. While we try and make
them reproducible, they'll have to be disabled in prod since they
prevent the image from building.
2021-11-12 02:40:50 +01:00
Giacomo Leidi 4fd4a778fc mobilizon-reshare.git: [native-inputs]: Add pytest-lazy-fixture. 2021-11-12 01:05:39 +01:00
Giacomo Leidi f12992c5d9
publishers: zulip: Let the user specify their instance. (#95) 2021-11-11 16:25:09 +01:00
Simone Robutti 5335ed8cc3
command tests (#97)
* filtering publications with inactive publishers

* filtering publications with inactive publishers

* WIP: Generate publications at runtime.

TODO:
- change `MobilizonEvent.compute_status`'s contract and break everything
- while we're at it we should remove `PublicationStatus.WAITING`
- test `storage.query.create_publications_for_publishers`

* cli: inspect_events: Unnest if-then-else.

* publishers: abstract: Remove `EventPublication.make`.

* fixed tests

* split query.py file

* added tests for get_unpublished_events

* added tests

* more tests

* added start test

* refactored start test

* added test start with db event

* added test recap

* added failed publication test

* added format test

Co-authored-by: Giacomo Leidi <goodoldpaul@autistici.org>
2021-11-11 16:20:50 +01:00
Simone Robutti 4dc1e4080a
fix publisher deactivation (#93)
* filtering publications with inactive publishers

* filtering publications with inactive publishers

* WIP: Generate publications at runtime.

TODO:
- change `MobilizonEvent.compute_status`'s contract and break everything
- while we're at it we should remove `PublicationStatus.WAITING`
- test `storage.query.create_publications_for_publishers`

* cli: inspect_events: Unnest if-then-else.

* publishers: abstract: Remove `EventPublication.make`.

* fixed tests

* split query.py file

* added tests for get_unpublished_events

* added tests

* more tests

* added start test

* main: start: Remove filter_publications_with_inactive_publishers.

Co-authored-by: Giacomo Leidi <goodoldpaul@autistici.org>
2021-11-11 15:18:04 +01:00
Giacomo Leidi 4f24d47f19
docker: image: Run cron jobs with root privileges. (#98) 2021-11-11 01:21:24 +01:00
Giacomo Leidi ba3eef4341
Docker image (#84)
* Add [guix](https://guix.gnu.org/) package.

This enables:

- [direnv](https://direnv.net/) integration to setup and tear down
  a suitable development environment;
- if you're not a direnv user you can always
  `guix environment -l guix.scm` to spawn a shell
  with all the necessary dependencies;
- Export of Mobilizon Reshare and its dependencies
  to one of the formats supported by `guix pack`. Right now they are:

    + tarball       Self-contained tarball, ready to run on another machine
    + squashfs      Squashfs image suitable for Singularity
    + docker        Docker image ready for 'docker load'
    + deb           Debian archive installable via dpkg/apt

* Add docker image and docker-compose.yml.

* Add Github CI workflow.
2021-10-31 01:55:25 +02:00
Giacomo Leidi 84e54a503e
Prevent dynaconf from merging different files. (#89) 2021-10-28 21:28:12 +02:00
Simone Robutti bc61ad6123
cli help messages (#85)
* added basic recap feature (no error handling)

* introduced abstractpublication

* extracted base reports

* added error report to recap

* added test

* added docs

* implemented publisher and formatter

* fixed API for recap

* removed redundant config validation

* added config sample

* added mobilizon link to templates

* added link format to telegram

* added mobilizon link to recap

* fixed config and emoji

* refactored commands

* added help messages

* improved format
2021-10-25 13:43:38 +02:00
Simone Robutti 41e82f5035
better error handling (#92)
* safe logging of notifier failure to send

* added test
2021-10-24 21:43:09 +02:00
Simone Robutti e16dd19a7c
simplified validation (#91) 2021-10-24 21:32:28 +02:00
Giacomo Leidi 6430de4a84
Add Mastodon publisher. (#83)
* Add Mastodon publisher.

This commit enables publishing on Mastodon and tries to define the
minimal requirements for adding a new platform to Mobilizon Reshare.

* publishers: exceptions: Add HTTPError.

* platforms: mastodon: Make toot length customizable.
2021-10-20 00:08:58 +02:00
Simone Robutti 8de70ef857
mobilizon link in template (#80)
* added basic recap feature (no error handling)

* introduced abstractpublication

* extracted base reports

* added error report to recap

* added test

* added docs

* implemented publisher and formatter

* fixed API for recap

* removed redundant config validation

* added config sample

* added mobilizon link to templates

* added link format to telegram

* added mobilizon link to recap

* fixed config and emoji
2021-10-19 07:35:18 +02:00
Simone Robutti 489d41179e
recap header (#79)
* added basic recap feature (no error handling)

* introduced abstractpublication

* extracted base reports

* added error report to recap

* added test

* added docs

* implemented publisher and formatter

* fixed API for recap

* removed redundant config validation

* added config sample

* added active publisher test

* added recap header template
2021-10-17 14:09:24 +02:00
Simone Robutti 71b65342b9
fix telegram active (#78)
* added basic recap feature (no error handling)

* introduced abstractpublication

* extracted base reports

* added error report to recap

* added test

* added docs

* implemented publisher and formatter

* fixed API for recap

* removed redundant config validation

* added config sample

* added active publisher test
2021-10-17 14:05:25 +02:00
Simone Robutti c14cdfb67f
twitter (#77)
* added basic recap feature (no error handling)

* introduced abstractpublication

* extracted base reports

* added error report to recap

* added test

* added docs

* implemented publisher and formatter

* fixed API for recap

* removed redundant config validation

* added config sample
2021-10-17 14:05:16 +02:00
Simone Robutti 5e171216d2
event recap (#69)
* added basic recap feature (no error handling)

* introduced abstractpublication

* extracted base reports

* added error report to recap

* added test

* added docs
2021-10-16 01:25:45 +02:00
Simone Robutti 5db7fb8597
Metadata (#68)
* decoupled notifiers from event

* stub

* publishers working

* fixed format CLI

* fixed unit tests

* renamed abstractnotifier

* added another excluded character

* restored bundled secrets file

* test telegram escape

* tested telegram event validation

* added telegram response validation

* added pragma

* added zulip response validation test

* added metadata to pyproject.toml

* improved documentation
2021-10-05 15:32:18 +02:00
Simone Robutti b61a2c5c3c
More tests (#67)
* decoupled notifiers from event

* stub

* publishers working

* fixed format CLI

* fixed unit tests

* renamed abstractnotifier

* added another excluded character

* restored bundled secrets file

* test telegram escape

* tested telegram event validation

* added telegram response validation

* added pragma

* added zulip response validation test
2021-10-05 15:32:07 +02:00
Simone Robutti bc212e7801
Check length (#66)
* decoupled notifiers from event

* stub

* publishers working

* fixed format CLI

* fixed unit tests

* renamed abstractnotifier

* added another excluded character

* restored bundled secrets file
2021-10-03 13:19:37 +02:00
Simone Robutti b6b2402767
Refactor publication (#65)
* decoupled notifiers from event

* stub

* publishers working

* fixed format CLI

* fixed unit tests

* renamed abstractnotifier

* added another excluded character
2021-10-02 18:09:03 +02:00
Giacomo Leidi 6f81522ad0 Release v0.1.0. 2021-09-28 11:40:04 +02:00
Giacomo Leidi bbf1ad7350 release.sh: Force POSIX compliance. 2021-09-28 11:38:13 +02:00
Simone Robutti 3258e1b1c9
Telegram format (#64)
* improved template

* improved location format
2021-09-27 09:20:01 +02:00
Giacomo Leidi 6654d13ed0
publishers: Add Zulip publisher. (#62)
* - publishers: Add Zulip publisher.
- README.md.: Add Zulip.
- LICENSE: `fold -s LICENSE | sed 's/ *$//g' > l; mv l LICENSE`

* tests: publishers: Test Zulip publisher.

* publishers: templates: Update Zulip template.

* zulip: Add more tests.

* release.sh: Safer publication.

* tests: publishers: Move zulip specific fixtures to test_zulip.py
2021-09-26 20:12:06 +02:00
Simone Robutti 360740eae0
format event cli (#61)
* added get_formatted_event

* fixed cli settings

* added format command

* refactored inspect
2021-09-09 23:04:19 +02:00
tinoilcotechino 394d84b0a5
settings.toml: Move secrets to dedicated file. (#60)
Configuration files are checked in this order:

      1. CLI argument
      2. `$MOBILIZION_RESHARE_SETTINGS_FILE` environment variable;
      3. User configuration directory. On Linux that's `$XDG_CONFIG_HOME/mobilizon_reshare/<mobilizon-reshare-version>`;
      4. System configuration directory. On Linux that's the first element in `$XDG_CONFIG_DIRS` + `/mobilizon_reshare/<mobilizon-reshare-version>`.
      5. The default configuration distributed with the package.

The first available configuration file will be loaded. Secrets can be set either
via environment variables (such as `export MOBILIZON_RESHARE_PUBLISHER_TELEGRAM_TOKEN="my-telegram-token"` )
or by setting the `$SECRETS_FOR_DYNACONF` environment variable to a `secrets.(toml|yaml|ini|json)` file.

Co-authored-by: Giacomo Leidi <goodoldpaul@autistici.org>
2021-09-07 23:39:58 +02:00