Commit Graph

40 Commits

Author SHA1 Message Date
Giacomo Leidi 6bd2d606df
Store notifications. (#180) 2023-05-22 13:00:37 +02:00
Giacomo Leidi 3874acf247
Failures (#183)
* Update beautifulsoup4 to 4.11.

* Update docker image.

* Add type annotations.

* Publish where you can and notify errors.

* Add tests for partial publishing.
2023-05-22 12:53:32 +02:00
Simone Robutti 370e00d187
decouple dataclasses from models (#181)
* fixed parsing bug

* implemented events and publications endpoints

split endpoints by entity

removed credentials

* add pagination (#179)

* added pagination

* integrated pagination with tortoise

* added test for publications

* removed converter file

* moved publications to dataclasses module

* implemented import pattern on dataclasses to prevent circular imports

* removed redundant fetch

* removed unused query

* split build_publications

* split failed_publications

* removed redundant query functions

* split publication retrieve

* split all read functions

* removed redundant write function

* fixed lock
2022-12-11 14:15:04 +01:00
Simone Robutti ddc706e201
Add publication crud (#178)
* fixed parsing bug

* implemented events and publications endpoints

split endpoints by entity

removed credentials

* add pagination (#179)

* added pagination

* integrated pagination with tortoise

* added test for publications

* removed converter file

* updated dependencies
2022-12-07 21:46:57 +01:00
Simone Robutti 63a30bb483
refactor coordinators (#171)
* introduced CommandConfig object

* added dry_run for start command

* added test to start_dry_run

* added dry_run recap

* fixed import

* improved printing

* fixed zulip debug info

* improved recap dry-run print

* moved coordinator classes into dedicated package

* removed unused init

* divided event coordinators from recap coordinators

* added some docstrings
2022-09-24 16:46:03 +02:00
Giacomo Leidi b66c94c8a2
Add publish command. (#167)
* Add publish command.

* publish: Add tests.

* Add list-platforms and test-configuration.

* Update Guix dependencies.

* Move publishing of events and publications to retry.
2022-05-17 23:14:52 +02:00
Simone Robutti 1217b17326
fix event retry (#152)
* added twitter error handling

* added facebook tests

* added header format test

* added multiple newlines check

* added test list command

* fixed commands structure

* fixed event retry

* fixed publication retry

* added publication tests

* removed unused option

* fixed list begin/end window

* added test retry failures

* linting

* refactored sender

* added timezone freeze

* fixed facebook-sdk and beatifulsoup errors
2022-03-06 10:41:02 +01:00
Simone Robutti 420f823dd4
platform tests (#150)
* added twitter error handling

* added facebook tests

* added header format test

* added multiple newlines check
2022-03-02 08:59:49 +01:00
Giacomo Leidi 529f83825e
Pave the way for using only EventPublications outside of storage module. (#149)
* Move `EventPublication.from_orm` to `storage.query.converter`.

Co-authored-by: Simone Robutti <simone.robutti@protonmail.com>
2022-02-23 17:26:13 +01:00
Simone Robutti f0a7449336
rework maintenance cli (#140)
* added default

* moved object before verb

* added event retry

* added publication_retry

* renamed inspect to list

* fixed retry publication

* fixed retry event and structure
2022-02-14 21:10:27 +01:00
magowiz 45802ecbdd
Feature/optimizing download (#118)
* add column last_update_time

* save last_update_time in event db record

* use id + updatedAt for comparison instead of mobilizon_id, this will treat updated events like new ones

* rework event selection/comparison to include unpublished with updates to ones need to be saved

* added update for unpublished events

* tests: test_update: Add create_unpublished_events tests.

* Move `MobilizonEvent.to_model` to `storage.query`

* Move `MobilizonEvent.from_model` to `storage.query`

* Move `MobilizonEvent.compute_status` to `storage.query`

* Move `publishers.exception.EventNotFound` to `storage.query.exceptions`
2022-02-09 00:54:56 +01:00
Giacomo Leidi ad8647704d
Add event name to notifications. (#136) 2022-02-05 18:46:48 +01:00
Simone Robutti 5804b55dd8
Fix markdown cropping (#128)
* fixed error log

* changed telegram publisher to use HTML format

* fixed dataclass update issue

* docker: Add python-telegram-bot.

* docker: mobilizon-reshare: Reenable non deterministic tests.

Co-authored-by: Giacomo Leidi <goodoldpaul@autistici.org>
2022-01-18 01:39:00 +01:00
Giacomo Leidi 43d653f37c
Update guix package definition after core-updates merge. (#122) 2022-01-03 20:14:31 +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 fee794be48 test: puslishers: Adapt Zulip tests to HTTPResponseError. 2021-11-28 17:25:43 +01:00
Giacomo Leidi f8bbd1df41
Fix publication exception handling for notification. (#105) 2021-11-27 23:31:44 +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
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 f12992c5d9
publishers: zulip: Let the user specify their instance. (#95) 2021-11-11 16:25:09 +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
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 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 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
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 09124b6358
Make `Event.mobilizon_id` a proper `UUIDField`. (#59)
This fixes #38.

Co-authored-by: Giacomo Leidi <goodoldpaul@autistici.org>
2021-08-29 14:51:52 +02:00
tinoilcotechino 489e3d66ad
Fix PublisherCoordinatorReport generation. (#54)
* Fix PublisherCoordinatorReport generation.

Without this patch we are given *either* the failed or the successful
publication reports. We actually need both, this patch implements the
merge.

* Reformat

Co-authored-by: Giacomo Leidi <goodoldpaul@autistici.org>
2021-08-28 13:17:39 +02:00
Simone Robutti 2197e07213
notify failure (#52)
* fixed visualization

* simplified tests

* split into files

* refactored test expected publications

* split update tests

* expanded specifications and tests

* added event_status window tests

* fixed 'all' command

* renamed everything

* fixed uppercase

* refactored main and publisher to add notifications

* tested report successful

* added tests to publisher coordinator

* added more coordinator tests

* test coordinator success
2021-08-27 23:45:24 +02:00
Simone Robutti 2c8063cf4a
rename everything (#50)
* fixed visualization

* simplified tests

* split into files

* refactored test expected publications

* split update tests

* expanded specifications and tests

* added event_status window tests

* fixed 'all' command

* renamed everything

* fixed uppercase
2021-08-16 10:49:52 +02:00
Simone Robutti 40919a994f
publication window (#24)
* added get events stub

* added event parsing

* removed datetime

* added config and tests

* fixed response format in test

* more tests

* added error handling for request

* improved dummy data

* added get_unpublished_events

* added test

* removed last_accessed

* mobilizon_url moved to fixture

* added config comments

* moved mobilizon group to config

* added method

* removed non-working test settings

* added publishing window logic and tests

* added inner/outer window check and mocking

* improved fixture

* fixed outer window

* fixed tests
2021-07-07 11:19:37 +02:00
SlyK182 de3e503cd6
Notification system (#13)
* Fixed typo

* Added proper exceptions for publishers

* Updated publishers logics: using messengers to allow publications without events

* Added new exception 'InvalidSettings'

* Updated notifiers and publishers: retrieve credentials and destination from config, use only message/event in constructors, lesser refactoring

* Updated publishers' tests

* Updated notifiers and publishers config for Telegram service, updated settings.toml file

* Updated 'post()' method and removed useless config checks for Telegram bot

* Added jinja2 template management for message formatting methods

* Manage message validation in publishers' run() method

* Better config management for notifiers and publishers

* Lesser update to logging and error-raising management (#23)
2021-07-05 21:44:11 +02:00
Simone Robutti a45c2c19ec added test predicates 2021-05-02 11:23:31 +02:00