Commit Graph

118 Commits

Author SHA1 Message Date
Josh McKinney d4956e943c
fix: next/prev page handling in Page struct
Improve the handling of next and previous pages in the `Page` struct
by fixing a bug that caused the URLs to be set to None when a page with
no data was loaded. This change allows for the next and previous page
URLs to be preserved for future retrieval even when there are no
results in the current page.
2023-04-26 18:53:23 -07:00
Josh McKinney 2f3daffa74 fix: authenticate in page_next/page_prev calls
Fixes the following error:

error err=Couldn't get next page

Caused by:
    0: Error encountered in the HTTP backend while requesting a route.
    1: HTTP status client error (401 Unauthorized) for url (https://hachyderm.io/api/v1/timelines/home?max_id=110196530215835290)
2023-04-14 05:05:44 -07:00
D. Scott Boggs e279f4bda7 Switch from the `is_variant` crate to the `derive_is_enum_variant` one. 2023-03-19 11:22:51 -04:00
D. Scott Boggs 7324a6c086 Fix stream urls 2023-02-27 08:51:29 -05:00
D. Scott Boggs 1884ea272c Pass client instance to the event stream 2023-02-13 12:22:46 -05:00
D. Scott Boggs 6f5a2a5e90 Add is_variant methods to all enums 2023-02-01 15:38:48 -05:00
D. Scott Boggs 2e8f8a4885 Fixes for breaking changes in the toml crate 2023-02-01 08:52:50 -05:00
D. Scott Boggs 77409389ac Drop dependency on serde_qs for now 2023-02-01 07:28:51 -05:00
D. Scott Boggs b6d6651869 Add a little more documentation 2023-01-29 06:13:53 -05:00
D. Scott Boggs b6fd884387 Add client method to wait for attachment processing 2023-01-29 06:13:53 -05:00
D. Scott Boggs e662eac46a Fix routes which take an Id type; fix doctests 2023-01-24 15:33:49 -05:00
D. Scott Boggs 53fc05d36f Add Id types to prelude and entities prelude to crate prelude 2023-01-24 15:33:49 -05:00
Sprite 2301fda307 Fix errors caused by sync locks crossing `await` in `cli::authenticate` 2023-01-20 16:55:26 -05:00
kuna 9084c1fcaa Update docs for Registration::new_with_client
Co-authored-by: Scott Boggs <dscottboggs@gmail.com>
2023-01-14 16:28:05 -05:00
baummarten d94bcd45d2 Mastodon::new now wraps Mastodon::new_with_client 2023-01-14 16:28:05 -05:00
baummarten 72d158513c Registration::new_with_client
Registration can now be created with a custom Reqwest Client.
2023-01-14 16:28:05 -05:00
D. Scott Boggs 6e044c3f35 Use `impl AsRef<str>` instead of `&str` to work with new ID types 2023-01-09 09:03:21 -05:00
D. Scott Boggs 10ec4dc81f Fix: backwards compatibility 2023-01-09 07:27:53 -05:00
D. Scott Boggs 14dc17e582 Split status_builder module into a few files 2023-01-09 07:27:53 -05:00
D. Scott Boggs cc6bd77cab Publish NewStatus fields 2023-01-09 07:27:53 -05:00
Matthias Beyer 6dcffc0802 Fix: Use Visibility pub here, to be backwards compatible
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-04 08:29:52 -05:00
Matthias Beyer af3facfbf0 Add mastodon_async_entities
This patch move the entities module to a helper-crate.

With this, we give the user the opportunity to use only the entities
types in their codebase, if need be.
One scenario where this is required came up in

    https://github.com/dscottboggs/mastodon-async/issues/38

TL;DR is: A user needed to be able to pass types like `Status` from a
backend part of an application to a frontend which was compiled to WASM.
Because mastodon_async depends on tokio, which does not compile to WASM
(at least not with the features required by mastodon_async).

One option would have been to provide types in the application code
which can be constructed from mastodon_asyncs entity types. This would
lead to _a lot_ of code duplication (over several projects still,... but
that's rather undesireable anyways).

The solution mastodon_async offers with this patch is a helper-crate
which only contains the entity types: mastodon_async_entities.

mastodon_async publicly exports the whole mastodon_async_entities crate,
so users do not have to depend on the latter directly.

In addition to the `entities` module from mastodon_async, also the
`Visibility` type had to be moved.

`mastodon_async_entities` also got an own `Error` type, which
`mastodon_async::Error` can of course wrap.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: D. Scott Boggs <scott@tams.tech>
2023-01-04 08:29:52 -05:00
Matthias Beyer 02de9f5d32 Fix: Remove unused import
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer 53447d1f48 Fix: Pass arguments in right order
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer 5d445d2708 Fix clippy: Remove unnecessary Ok + ? operator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer 88ba4c0894 Fix clippy: Remove unnecessary Ok + ? operator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer 00c390f56b fixup! Add error variant for when not all bytes are written 2023-01-03 07:13:25 -05:00
D. Scott Boggs 1e4b2e0adb use serde_json's to_writer 2023-01-03 07:13:25 -05:00
Matthias Beyer dbbdb8e5c0 Add error variant for when not all bytes are written
cargo-clippy tells us that the `crate::helpers::json::to_writer` and
`crate::helpers::toml::to_writer` functions were implemented without
checking the return value of the `write()` function called inside.

That might lead to serious issues on the user site, if indeed not all
bytes were written.

This patch fixes the issue of the user not knowning about the issue by
introducing a new error variant and returning it in case of unfinished
writes.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 07:13:25 -05:00
Matthias Beyer c32f628c49 Make Registered::complete() accept an AsRef<str>
This patch changes the signature of `Registered::complete` to accept an
`AsRef<str>`. This _should_ be backwards compatible to the old version.

This change was implemented as it has the neat benefit that a user can
implement a type that does not implement `Debug` or `Display`, but only
`AsRef<str>`.
This can be done to ensure that the access code is not accidentially
shown in log output, which might be pasted to some code forge for bug
reporting.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 14:07:09 -05:00
D. Scott Boggs f037379d0f drop dependency on hyper-old-types in favor of parse_link_header 2022-12-29 14:06:07 -05:00
Matthias Beyer 5832111f46 Replace dependency "chrono" with "time"
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 13:43:26 -05:00
D. Scott Boggs 96fbef900e Change error implementation to use thiserror 2022-12-29 13:27:41 -05:00
Matthias Beyer c689b8390c Run cargo-fmt on whole codebase
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 07:14:00 -05:00
D. Scott Boggs 351bb0741b spelling and clippy fixes 2022-12-29 06:41:57 -05:00
Matthias Beyer 963a3323ea Optimize: Remove clone() call
This patch makes the `Headers` helper type that is only used to be able
to implement Serialize on it only contain a reference to the actual
headers. This way we don't need to clone() the object returned by
`reqwest::Repsonse::headers()`.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 05:58:30 -05:00
D. Scott Boggs 5c764185bb Rewrite awkward code 2022-12-28 15:35:39 -05:00
D. Scott Boggs f82725c9dc Add dependency on percent_encoding
percent_encoding used to be a part of url before v2.
2022-12-28 09:39:49 -05:00
D. Scott Boggs 4fb24a5a21 Drop the magic bullshit
There were too many false positive responses from libmagic to have this
just happen in the background. In a future release I may add a specific
error which is returned when the given file has no extension, and
downstream application developers can use that as an indicator that they
should ask the user if they want to detect the filetype, making use of
libmagic directly in the downstream application as appropriate.
2022-12-28 08:49:43 -05:00
D. Scott Boggs 7653513c6f Wrap magic cookie in a mutex
This commit also includes benchmarks proving the viability of reloading the
magic database for every filetype request, should that become necessary.
2022-12-28 08:49:43 -05:00
Matthias Beyer 29463764c1
Fix clippy: Derive Eq for Data
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:08:43 +01:00
Matthias Beyer afb3f59fc7
Fix clippy: Derive Eq for MediaType
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:08:24 +01:00
Matthias Beyer 8cfe447aa1
Fix clippy: Derive Eq for Card
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:08:13 +01:00
Matthias Beyer ee4e00affd
Fix clippy: Derive Eq for Filter
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:07:51 +01:00
Matthias Beyer 609ddc895b
Fix clippy: Derive Eq for AddFilterRequest
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:07:24 +01:00
Matthias Beyer 789fbd69f5
Fix clippy: Derive Eq for FilterContext
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:05:52 +01:00
Matthias Beyer bf9bad441f
Fix clippy: Derive Eq for StreamingApi
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:05:31 +01:00
Matthias Beyer 738d97d65f
Fix clippy: Derive Eq for Stats
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:05:05 +01:00
Matthias Beyer 0e2ee6717f
Fix clippy: Derive Eq for List
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:04:53 +01:00
Matthias Beyer e3539a46ba
Fix clippy: Derive Eq for Mention
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-27 19:04:40 +01:00