vkdart

Форк
0
130 строк · 5.2 Кб
1
import 'package:vkdart/util.dart';
2
import 'package:vkdart/vkontakte.dart';
3

4
/// Model Wall.
5
///
6
/// See https://dev.vk.com/ru/reference/objects/wall
7
class WallAttachmentModel extends CustomAttachmentModel
8
    with AttachmentLikesMixin, AttachmentRepostsMixin {
9
  // ignore: public_member_api_docs
10
  WallAttachmentModel(super.payload) : super(attachType: 'wall');
11

12
  @override
13
  int get ownerId => payload['owner_id'] ?? payload['to_id'];
14

15
  /// The ID of the author of the record (on whose behalf the record was published).
16
  int? get fromId => payload['from_id'];
17

18
  /// The ID of the administrator who published the entry (returned only for communities when requested with an administrator access key).
19
  /// It is returned in records published less than 24 hours ago.
20
  int? get createdUserId => payload['created_by'];
21

22
  /// The time when the record was published in unixtime format.
23
  int? get createdAt => payload['date'];
24

25
  /// Text wall.
26
  String? get text => payload['text'];
27

28
  /// The ID of the owner of the record in response to which the current one was left.
29
  int? get replyOwnerId => payload['reply_owner_id'];
30

31
  /// ID of the record that the current one was left in response to.
32
  int? get replyPostId => payload['reply_post_id'];
33

34
  /// `1`, if the record was created with the "Friends only" option.
35
  bool? get isFriendsOnly => checkBoolInProperty('friends_only');
36

37
  Map<String, dynamic>? get _comments => payload['comments'];
38
  Map<String, dynamic>? get _copyright => payload['copyright'];
39

40
  /// number of comments;
41
  int? get commentsCount => _comments?['count'];
42

43
  /// information about whether the current user can comment on the entry ;
44
  bool? get isCommentsCanPost => checkBoolUtil(_comments?['can_post']);
45

46
  /// information about whether communities can comment on the post;
47
  bool? get isCommentsGroupsCanPost =>
48
      checkBoolUtil(_comments?['groups_can_post']);
49

50
  /// Can the current user close comments on the post;
51
  bool? get isCommentsCanClose => checkBoolUtil(_comments?['can_close']);
52

53
  /// whether the current user can open comments on the post.
54
  bool? get isCommentsCanOpen => checkBoolUtil(_comments?['can_open']);
55

56
  // ignore: public_member_api_docs
57
  int get copyrightId => _copyright?['id'];
58
  // ignore: public_member_api_docs
59
  String? get copyrightLink => _copyright?['link'];
60
  // ignore: public_member_api_docs
61
  String? get copyrightName => _copyright?['name'];
62
  // ignore: public_member_api_docs
63
  String? get copyrightType => _copyright?['type'];
64

65
  /// the number of views of the wall.
66
  int? get viewsCount => payload['views']?['count'];
67

68
  /// The record type can take the following values: post, `copy`, `reply`, `postpone`, `suggest`.
69
  String? get postType => payload['post_type'];
70

71
  /// Information about the recording placement method.
72
  /// See https://vk.com/dev/objects/wall#post_source
73
  Map<String, dynamic>? get postSource => payload['post_source'];
74

75
  /// An array of objects corresponding to media resources attached to a record: photos, documents, video files, and others.
76
  /// See https://dev.vk.com/ru/reference/objects/wall#attachments
77
  List<AttachmentModel> get attachments =>
78
      transformAttachments((payload['attachments'] as List?)
79
              ?.map((e) => (e as Map).cast<String, dynamic>())
80
              .toList() ??
81
          const []);
82

83
  /// type of place;
84
  String? get geoType => payload['geo']?['type'];
85

86
  /// location coordinates;
87
  String? get geoCoordinates => payload['geo']?['coordinates'];
88

89
  /// description of the place (if it has been added).
90
  /// See https://dev.vk.com/ru/reference/objects/wall#geo
91
  Map<String, dynamic>? get geoPlace => payload['geo']?['place'];
92

93
  /// The ID of the author, if the entry was published on behalf of the community and signed by the user;
94
  int? get signerId => payload['signer_id'];
95

96
  /// An array containing the history of reposts to be recorded.
97
  /// It is returned only if the record is a repost.
98
  /// Each of the array objects, in turn, is a standard format record object.
99
  List<WallAttachmentModel>? get copyHistory =>
100
      (payload['copy_history'] as List?)
101
          ?.map((e) => WallAttachmentModel((e as Map).cast<String, dynamic>()))
102
          .toList();
103

104
  /// Information about whether the current user can pin the record
105
  bool? get isCanPin => checkBoolInProperty('can_pin');
106

107
  /// Information about whether the current user can delete an entry
108
  bool? get isCanDelete => checkBoolInProperty('can_delete');
109

110
  /// Information about whether the current user can edit the record
111
  bool? get isCanEdit => checkBoolInProperty('can_edit');
112

113
  /// Information that the record is pinned.
114
  bool? get isPinned => checkBoolInProperty('is_pinned');
115

116
  /// Information about whether the record contains the mark "advertising"
117
  bool? get isMarkedAsAds => checkBoolInProperty('marked_as_ads');
118

119
  /// `true` if the object has been added to the bookmarks of the current user.
120
  bool? get isFavorite => payload['is_favorite'];
121

122
  /// Information about VK Donut entry:
123
  ///
124
  /// See https://dev.vk.com/ru/reference/objects/wall#donut
125
  Map<String, dynamic>? get donut => payload['donut'];
126

127
  /// ID of the deferred record.
128
  /// This field is returned when the recording was on the timer.
129
  int? get postponedId => payload['postponed_id'];
130
}
131

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.