1
import 'package:vkdart/util.dart';
2
import 'package:vkdart/vkontakte.dart';
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');
13
int get ownerId => payload['owner_id'] ?? payload['to_id'];
15
/// The ID of the author of the record (on whose behalf the record was published).
16
int? get fromId => payload['from_id'];
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'];
22
/// The time when the record was published in unixtime format.
23
int? get createdAt => payload['date'];
26
String? get text => payload['text'];
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'];
31
/// ID of the record that the current one was left in response to.
32
int? get replyPostId => payload['reply_post_id'];
34
/// `1`, if the record was created with the "Friends only" option.
35
bool? get isFriendsOnly => checkBoolInProperty('friends_only');
37
Map<String, dynamic>? get _comments => payload['comments'];
38
Map<String, dynamic>? get _copyright => payload['copyright'];
40
/// number of comments;
41
int? get commentsCount => _comments?['count'];
43
/// information about whether the current user can comment on the entry ;
44
bool? get isCommentsCanPost => checkBoolUtil(_comments?['can_post']);
46
/// information about whether communities can comment on the post;
47
bool? get isCommentsGroupsCanPost =>
48
checkBoolUtil(_comments?['groups_can_post']);
50
/// Can the current user close comments on the post;
51
bool? get isCommentsCanClose => checkBoolUtil(_comments?['can_close']);
53
/// whether the current user can open comments on the post.
54
bool? get isCommentsCanOpen => checkBoolUtil(_comments?['can_open']);
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'];
65
/// the number of views of the wall.
66
int? get viewsCount => payload['views']?['count'];
68
/// The record type can take the following values: post, `copy`, `reply`, `postpone`, `suggest`.
69
String? get postType => payload['post_type'];
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'];
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>())
84
String? get geoType => payload['geo']?['type'];
86
/// location coordinates;
87
String? get geoCoordinates => payload['geo']?['coordinates'];
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'];
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'];
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>()))
104
/// Information about whether the current user can pin the record
105
bool? get isCanPin => checkBoolInProperty('can_pin');
107
/// Information about whether the current user can delete an entry
108
bool? get isCanDelete => checkBoolInProperty('can_delete');
110
/// Information about whether the current user can edit the record
111
bool? get isCanEdit => checkBoolInProperty('can_edit');
113
/// Information that the record is pinned.
114
bool? get isPinned => checkBoolInProperty('is_pinned');
116
/// Information about whether the record contains the mark "advertising"
117
bool? get isMarkedAsAds => checkBoolInProperty('marked_as_ads');
119
/// `true` if the object has been added to the bookmarks of the current user.
120
bool? get isFavorite => payload['is_favorite'];
122
/// Information about VK Donut entry:
124
/// See https://dev.vk.com/ru/reference/objects/wall#donut
125
Map<String, dynamic>? get donut => payload['donut'];
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'];