1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
package Mastodon::Entity::Status;
use strict;
use warnings;
our $VERSION = '0.017';
use Moo;
with 'Mastodon::Role::Entity';
use Types::Standard qw( Maybe Int Str Bool ArrayRef Enum );
use Mastodon::Types qw(
URI Account Status DateTime Attachment Mention Tag Application
);
use Log::Any;
my $log = Log::Any->get_logger( category => 'Mastodon' );
has account => (
is => 'ro', isa => Account, coerce => 1, required => 1,
);
has application => (
is => 'ro', isa => Maybe [Application], coerce => 1,
);
has content => (
is => 'ro', isa => Str,
);
has created_at => (
is => 'ro', isa => DateTime, coerce => 1,
);
has emojis => (
is => 'ro', isa => ArrayRef,
);
has favourited => (
is => 'ro', isa => Bool, coerce => 1,
);
has favourites_count => (
is => 'ro', isa => Int, required => 1,
);
has id => (
is => 'ro', isa => Int,
);
has in_reply_to_account_id => (
is => 'ro', isa => Maybe [Int],
);
has in_reply_to_id => (
is => 'ro', isa => Maybe [Int],
);
has media_attachments => (
is => 'ro', isa => ArrayRef [Attachment], coerce => 1,
);
has mentions => (
is => 'ro', isa => ArrayRef [Mention], coerce => 1,
);
has reblog => (
is => 'ro', isa => Maybe [Status], coerce => 1,
);
has reblogged => (
is => 'ro', isa => Bool, coerce => 1,
);
has reblogs_count => (
is => 'ro', isa => Int,
);
has sensitive => (
is => 'ro', isa => Bool, coerce => 1,
);
has spoiler_text => (
is => 'ro', isa => Str,
);
has tags => (
is => 'ro', isa => ArrayRef [Tag], coerce => 1,
);
has uri => (
is => 'ro', isa => Str,
);
has url => (
is => 'ro', isa => URI, coerce => 1,
);
has visibility => (
is => 'ro', isa => Enum[qw(
public unlisted private direct
)],
required => 1,
);
foreach my $pair (
[ fetch => 'get_status' ],
[ fetch_context => 'get_status_context' ],
[ fetch_card => 'get_status_card' ],
[ fetch_reblogs => 'get_status_reblogs' ],
[ fetch_favourites => 'get_status_favourites' ],
[ delete => 'delete_status' ],
[ boost => 'reblog' ],
[ unboost => 'unreblog' ],
[ favourite => undef ],
[ unfavourite => undef ],
) {
my ($name, $method) = @{$pair};
$method //= $name;
no strict 'refs';
*{ __PACKAGE__ . '::' . $name } = sub {
my $self = shift;
croak $log->fatal(qq{Cannot call '$name' without client})
unless $self->_client;
$self->_client->$method($self->id, @_);
};
}
1;
=encoding utf8
=head1 NAME
Mastodon::Entity::Status - A Mastodon status
=head1 DESCRIPTION
This object should not be manually created. It is intended to be generated
from the data received from a Mastodon server using the coercions in
L<Mastodon::Types>.
For current information, see the
L<Mastodon API documentation|https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#status>
=head1 ATTRIBUTES
=over 4
=item B<id>
The ID of the status.
=item B<uri>
A Fediverse-unique resource ID.
=item B<url>
URL to the status page (can be remote).
=item B<account>
The L<Mastodon::Entity::Account> which posted the status.
=item B<in_reply_to_id>
C<undef> or the ID of the status it replies to.
=item B<in_reply_to_account_id>
C<undef> or the ID of the account it replies to.
=item B<reblog>
C<undef> or the reblogged L<Mastodon::Entity::Status>.
=item B<content>
Body of the status; this will contain HTML (remote HTML already sanitized).
=item B<created_at>
The time the status was created as a L<DateTime> object.
=item B<reblogs_count>
The number of reblogs for the status.
=item B<favourites_count>
The number of favourites for the status.
=item B<reblogged>
Whether the authenticated user has reblogged the status.
=item B<favourited>
Whether the authenticated user has favourited the status.
=item B<sensitive>
Whether media attachments should be hidden by default.
=item B<spoiler_text>
If not empty, warning text that should be displayed before the actual content.
=item B<visibility>
One of: C<public>, C<unlisted>, C<private>, C<direct>.
=item B<media_attachments>
An array of L<Mastodon::Entity::Attachment> objects.
=item B<mentions>
An array of L<Mastodon::Entity::Mention> objects.
=item B<tags>
An array of L<Mastodon::Entity::Tag> objects.
=item B<application>
Application from which the status was posted, as a
L<Mastodon::Entity::Application> object.
=back
=head1 METHODS
This class provides the following convenience methods. They act as a shortcut,
passing the appropriate identifier of the current object as the first argument
to the corresponding methods in L<Mastodon::Client>.
=over 4
=item B<fetch>
A shortcut to C<get_status>.
=item B<fetch_context>
A shortcut to C<get_status_context>.
=item B<fetch_card>
A shortcut to C<get_status_card>.
=item B<fetch_reblogs>
A shortcut to C<get_status_reblogs>.
=item B<fetch_favourites>
A shortcut to C<get_status_favourites>.
=item B<delete>
A shortcut to C<delete_status>.
=item B<boost>
A shortcut to C<reblog>.
=item B<unboost>
A shortcut to C<unreblog>.
=item B<favourite>
A shortcut to C<favourite>.
=item B<unfavourite>
A shortcut to C<unfavourite>.
=back
=head1 AUTHOR
=over 4
=item *
José Joaquín Atria <jjatria@cpan.org>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by José Joaquín Atria.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|