Skip to content

Commit

Permalink
Merge #119
Browse files Browse the repository at this point in the history
119: feat: fixed for the issue (#118) r=myConsciousness a=myConsciousness

# 1. Description

<!-- Provide a description of what this PR is doing.
If you're modifying existing behavior, describe the existing behavior, how this PR is changing it,
and what motivated the change. If this is a breaking change, specify explicitly which APIs have been
changed. -->

## 1.1. Checklist

<!-- Before you create this PR confirm that it meets all requirements listed below by checking the
relevant checkboxes (`[x]`). This will ensure a smooth and quick review process. -->

- [x] The title of my PR starts with a [Conventional Commit] prefix (`fix:`, `feat:`, `docs:` etc).
- [x] I have read the [Contributor Guide] and followed the process outlined for submitting PRs.
- [x] I have updated/added tests for ALL new/updated/fixed functionality.
- [x] I have updated/added relevant documentation in `docs` and added dartdoc comments with `///`.
- [x] I have updated/added relevant examples in `examples`.

## 1.2. Breaking Change

<!-- Does your PR require users to manually update their apps to accommodate your change?

If the PR is a breaking change this should be indicated with suffix "!"  (for example, `feat!:`, `fix!:`). See [Conventional Commit] for details.
-->

- [ ] Yes, this is a breaking change.
- [x] No, this is _not_ a breaking change.

## 1.3. Related Issues

<!-- Provide a list of issues related to this PR from the [issue database].
Indicate which of these issues are resolved or fixed by this PR, i.e. Fixes #xxxx* !-->

<!-- Links -->

[issue database]: https://github.com/mastodon-dart/mastodon-api/issues
[contributor guide]: https://github.com/mastodon-dart/mastodon-api/blob/main/CONTRIBUTING.md
[style guide]: https://github.com/mastodon-dart/mastodon-api/blob/main/STYLEGUIDE.md
[conventional commit]: https://conventionalcommits.org


Co-authored-by: myConsciousness <contact@shinyakato.dev>
  • Loading branch information
bors[bot] and myConsciousness committed Feb 4, 2023
2 parents 5b126ce + 0cc9f7e commit 2f07585
Show file tree
Hide file tree
Showing 30 changed files with 1,266 additions and 93 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
{
"cSpell.words": [
"blurhash",
"Favourite",
"Favourited",
"favourites",
"flac",
"iframe",
"Kato",
"quicktime",
"ratelimit",
"Reblog",
"Reblogged",
"reblogs",
"Shinya",
"shortcode",
"unbookmark",
"unfavourite",
"Unfollow",
"Unmute",
"unreblog",
"Unreviewed",
"vorbis",
"webfinger",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ Future<void> main() async {
| [PATCH /api/v1/accounts/update_credentials](https://docs.joinmastodon.org/methods/accounts/#verify_credentials) | [updateAccount](https://pub.dev/documentation/mastodon_api/latest/mastodon_api/AccountsV1Service/updateAccount.html) |
| [PATCH /api/v1/accounts/update_credentials](https://docs.joinmastodon.org/methods/accounts/#verify_credentials) | [updateAvatarImage](https://pub.dev/documentation/mastodon_api/latest/mastodon_api/AccountsV1Service/updateAvatarImage.html) |
| [PATCH /api/v1/accounts/update_credentials](https://docs.joinmastodon.org/methods/accounts/#verify_credentials) | [updateHeaderImage](https://pub.dev/documentation/mastodon_api/latest/mastodon_api/AccountsV1Service/updateHeaderImage.html) |
| [GET /api/v1/accounts/:id](https://docs.joinmastodon.org/methods/accounts/#get) | [lookupById](https://pub.dev/documentation/mastodon_api/latest/mastodon_api/AccountsV1Service/lookupById.html) |
| [GET /api/v1/accounts/:id](https://docs.joinmastodon.org/methods/accounts/#get) | [lookupAccount](https://pub.dev/documentation/mastodon_api/latest/mastodon_api/AccountsV1Service/lookupAccount.html) |
| [GET /api/v1/accounts/:id/statuses](https://docs.joinmastodon.org/methods/accounts/#statuses) | [lookupStatuses](https://pub.dev/documentation/mastodon_api/latest/mastodon_api/AccountsV1Service/lookupStatuses.html) |
| [GET /api/v1/accounts/:id/followers](https://docs.joinmastodon.org/methods/accounts/#followers) | [lookupFollowers](https://pub.dev/documentation/mastodon_api/latest/mastodon_api/AccountsV1Service/lookupFollowers.html) |
| [GET /api/v1/accounts/:id/following](https://docs.joinmastodon.org/methods/accounts/#following) | [lookupFollowings](https://pub.dev/documentation/mastodon_api/latest/mastodon_api/AccountsV1Service/lookupFollowings.html) |
Expand Down
3 changes: 3 additions & 0 deletions lib/mastodon_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export 'package:mastodon_api/src/service/entities/report.dart';
export 'package:mastodon_api/src/service/entities/report_category.dart';
export 'package:mastodon_api/src/service/entities/rule.dart';
export 'package:mastodon_api/src/service/entities/status.dart';
export 'package:mastodon_api/src/service/entities/status_context.dart';
export 'package:mastodon_api/src/service/entities/status_edit.dart';
export 'package:mastodon_api/src/service/entities/status_snapshot.dart';
export 'package:mastodon_api/src/service/entities/status_source.dart';
export 'package:mastodon_api/src/service/entities/suggested_reason.dart';
export 'package:mastodon_api/src/service/entities/suggestion.dart';
export 'package:mastodon_api/src/service/entities/tag.dart';
Expand Down
6 changes: 4 additions & 2 deletions lib/src/core/exception/data_not_found_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class DataNotFoundException extends MastodonException {
..writeln(' $body\n');
}

buffer.writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.');
buffer
..writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.')
..writeln(' https://github.com/mastodon-dart/mastodon-api/issues');

return buffer.toString();
}
Expand Down
6 changes: 4 additions & 2 deletions lib/src/core/exception/mastodon_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ class MastodonException implements Exception {
}
}

buffer.writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.');
buffer
..writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.')
..writeln(' https://github.com/mastodon-dart/mastodon-api/issues');

return buffer.toString();
}
Expand Down
6 changes: 4 additions & 2 deletions lib/src/core/exception/mastodon_upload_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ class MastodonUploadException extends MastodonException {
}
}

buffer.writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.');
buffer
..writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.')
..writeln(' https://github.com/mastodon-dart/mastodon-api/issues');

return buffer.toString();
}
Expand Down
6 changes: 4 additions & 2 deletions lib/src/core/exception/rate_limit_exceeded_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ class RateLimitExceededException extends MastodonException {
..writeln(' $body\n');
}

buffer.writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.');
buffer
..writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.')
..writeln(' https://github.com/mastodon-dart/mastodon-api/issues');

return buffer.toString();
}
Expand Down
6 changes: 4 additions & 2 deletions lib/src/core/exception/unauthorized_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class UnauthorizedException extends MastodonException {
}
}

buffer.writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.');
buffer
..writeln(' Please create an Issue if you have a question '
'or suggestion for this exception.')
..writeln(' https://github.com/mastodon-dart/mastodon-api/issues');

return buffer.toString();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/service/entities/preview_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PreviewCard with _$PreviewCard {
@JsonKey(name: 'blurhash') String? blurHash,

/// Usage statistics for given days (typically the past week).
@JsonKey(name: 'history') required List<UsageStatistics> histories,
@JsonKey(name: 'history') required List<UsageStatistics> usageHistory,
}) = _PreviewCard;

factory PreviewCard.fromJson(Map<String, Object?> json) =>
Expand Down
51 changes: 27 additions & 24 deletions lib/src/service/entities/preview_card.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mixin _$PreviewCard {

/// Usage statistics for given days (typically the past week).
@JsonKey(name: 'history')
List<UsageStatistics> get histories => throw _privateConstructorUsedError;
List<UsageStatistics> get usageHistory => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
Expand Down Expand Up @@ -96,7 +96,7 @@ abstract class $PreviewCardCopyWith<$Res> {
@JsonKey(name: 'image') String? imageUrl,
String embedUrl,
@JsonKey(name: 'blurhash') String? blurHash,
@JsonKey(name: 'history') List<UsageStatistics> histories});
@JsonKey(name: 'history') List<UsageStatistics> usageHistory});
}

/// @nodoc
Expand Down Expand Up @@ -126,7 +126,7 @@ class _$PreviewCardCopyWithImpl<$Res, $Val extends PreviewCard>
Object? imageUrl = freezed,
Object? embedUrl = null,
Object? blurHash = freezed,
Object? histories = null,
Object? usageHistory = null,
}) {
return _then(_value.copyWith(
url: null == url
Expand Down Expand Up @@ -185,9 +185,9 @@ class _$PreviewCardCopyWithImpl<$Res, $Val extends PreviewCard>
? _value.blurHash
: blurHash // ignore: cast_nullable_to_non_nullable
as String?,
histories: null == histories
? _value.histories
: histories // ignore: cast_nullable_to_non_nullable
usageHistory: null == usageHistory
? _value.usageHistory
: usageHistory // ignore: cast_nullable_to_non_nullable
as List<UsageStatistics>,
) as $Val);
}
Expand Down Expand Up @@ -216,7 +216,7 @@ abstract class _$$_PreviewCardCopyWith<$Res>
@JsonKey(name: 'image') String? imageUrl,
String embedUrl,
@JsonKey(name: 'blurhash') String? blurHash,
@JsonKey(name: 'history') List<UsageStatistics> histories});
@JsonKey(name: 'history') List<UsageStatistics> usageHistory});
}

/// @nodoc
Expand Down Expand Up @@ -244,7 +244,7 @@ class __$$_PreviewCardCopyWithImpl<$Res>
Object? imageUrl = freezed,
Object? embedUrl = null,
Object? blurHash = freezed,
Object? histories = null,
Object? usageHistory = null,
}) {
return _then(_$_PreviewCard(
url: null == url
Expand Down Expand Up @@ -303,9 +303,9 @@ class __$$_PreviewCardCopyWithImpl<$Res>
? _value.blurHash
: blurHash // ignore: cast_nullable_to_non_nullable
as String?,
histories: null == histories
? _value._histories
: histories // ignore: cast_nullable_to_non_nullable
usageHistory: null == usageHistory
? _value._usageHistory
: usageHistory // ignore: cast_nullable_to_non_nullable
as List<UsageStatistics>,
));
}
Expand All @@ -326,11 +326,14 @@ class _$_PreviewCard implements _PreviewCard {
required this.html,
required this.width,
required this.height,
@JsonKey(name: 'image') this.imageUrl,
@JsonKey(name: 'image')
this.imageUrl,
required this.embedUrl,
@JsonKey(name: 'blurhash') this.blurHash,
@JsonKey(name: 'history') required final List<UsageStatistics> histories})
: _histories = histories;
@JsonKey(name: 'blurhash')
this.blurHash,
@JsonKey(name: 'history')
required final List<UsageStatistics> usageHistory})
: _usageHistory = usageHistory;

factory _$_PreviewCard.fromJson(Map<String, dynamic> json) =>
_$$_PreviewCardFromJson(json);
Expand Down Expand Up @@ -395,20 +398,20 @@ class _$_PreviewCard implements _PreviewCard {
final String? blurHash;

/// Usage statistics for given days (typically the past week).
final List<UsageStatistics> _histories;
final List<UsageStatistics> _usageHistory;

/// Usage statistics for given days (typically the past week).
@override
@JsonKey(name: 'history')
List<UsageStatistics> get histories {
if (_histories is EqualUnmodifiableListView) return _histories;
List<UsageStatistics> get usageHistory {
if (_usageHistory is EqualUnmodifiableListView) return _usageHistory;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_histories);
return EqualUnmodifiableListView(_usageHistory);
}

@override
String toString() {
return 'PreviewCard(url: $url, title: $title, description: $description, type: $type, authorName: $authorName, authorUrl: $authorUrl, providerName: $providerName, providerUrl: $providerUrl, html: $html, width: $width, height: $height, imageUrl: $imageUrl, embedUrl: $embedUrl, blurHash: $blurHash, histories: $histories)';
return 'PreviewCard(url: $url, title: $title, description: $description, type: $type, authorName: $authorName, authorUrl: $authorUrl, providerName: $providerName, providerUrl: $providerUrl, html: $html, width: $width, height: $height, imageUrl: $imageUrl, embedUrl: $embedUrl, blurHash: $blurHash, usageHistory: $usageHistory)';
}

@override
Expand Down Expand Up @@ -439,7 +442,7 @@ class _$_PreviewCard implements _PreviewCard {
(identical(other.blurHash, blurHash) ||
other.blurHash == blurHash) &&
const DeepCollectionEquality()
.equals(other._histories, _histories));
.equals(other._usageHistory, _usageHistory));
}

@JsonKey(ignore: true)
Expand All @@ -460,7 +463,7 @@ class _$_PreviewCard implements _PreviewCard {
imageUrl,
embedUrl,
blurHash,
const DeepCollectionEquality().hash(_histories));
const DeepCollectionEquality().hash(_usageHistory));

@JsonKey(ignore: true)
@override
Expand Down Expand Up @@ -495,7 +498,7 @@ abstract class _PreviewCard implements PreviewCard {
@JsonKey(name: 'blurhash')
final String? blurHash,
@JsonKey(name: 'history')
required final List<UsageStatistics> histories}) = _$_PreviewCard;
required final List<UsageStatistics> usageHistory}) = _$_PreviewCard;

factory _PreviewCard.fromJson(Map<String, dynamic> json) =
_$_PreviewCard.fromJson;
Expand Down Expand Up @@ -563,7 +566,7 @@ abstract class _PreviewCard implements PreviewCard {

/// Usage statistics for given days (typically the past week).
@JsonKey(name: 'history')
List<UsageStatistics> get histories;
List<UsageStatistics> get usageHistory;
@override
@JsonKey(ignore: true)
_$$_PreviewCardCopyWith<_$_PreviewCard> get copyWith =>
Expand Down
6 changes: 3 additions & 3 deletions lib/src/service/entities/preview_card.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion lib/src/service/entities/status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
// 📦 Package imports:
import 'package:freezed_annotation/freezed_annotation.dart';

import '../../core/language.dart';
import '../../core/visibility.dart';
import 'account.dart';
import 'application.dart';
import 'emoji.dart';
import 'media_attachment.dart';
import 'poll.dart';
import 'tag.dart';

// 🌎 Project imports:
import '../../../mastodon_api.dart';

part 'status.freezed.dart';
part 'status.g.dart';
Expand Down
4 changes: 1 addition & 3 deletions lib/src/service/entities/status_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

// 📦 Package imports:
import 'package:freezed_annotation/freezed_annotation.dart';

// 🌎 Project imports:
import '../../../mastodon_api.dart';
import 'status.dart';

part 'status_context.freezed.dart';
part 'status_context.g.dart';
Expand Down
56 changes: 56 additions & 0 deletions lib/src/service/entities/status_edit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2023 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

// ignore_for_file: invalid_annotation_target

// 📦 Package imports:
import 'package:freezed_annotation/freezed_annotation.dart';

import 'account.dart';
import 'emoji.dart';
import 'media_attachment.dart';
import 'poll.dart';

part 'status_edit.freezed.dart';
part 'status_edit.g.dart';

/// Represents a revision of a status that has been edited.
@freezed
class StatusEdit with _$StatusEdit {
@JsonSerializable(includeIfNull: false)
const factory StatusEdit({
/// The content of the status at this revision.
required String content,

/// The content of the subject or content warning at this revision.
required String spoilerText,

/// The account that published this revision.
required Account account,

/// The current state of the poll options at this revision.
///
/// Note that edits changing the poll options will be collapsed together
/// into one edit, since this action resets the poll.
Poll? poll,

/// The current state of the poll options at this revision.
///
/// Note that edits changing the poll options will be collapsed together
/// into one edit, since this action resets the poll.
required List<MediaAttachment> mediaAttachments,

/// Any custom emoji that are used in the current revision.
required List<Emoji> emojis,

/// Whether the status was marked sensitive at this revision.
@JsonKey(name: 'sensitive') required bool isSensitive,

/// The timestamp of when the revision was published.
required DateTime createdAt,
}) = _StatusEdit;

factory StatusEdit.fromJson(Map<String, Object?> json) =>
_$StatusEditFromJson(json);
}

0 comments on commit 2f07585

Please sign in to comment.