| 1 | package Reddit::Client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | our $VERSION = '1.395'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # 1.395 2/15/23 duplicates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # 1.394 8/16/21 Added third argument to approve_user, for unapprove | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # 1.394 Added unapprove_user, alias for approve_user with unapprove arg set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # Not in yet: gallery links to Link | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Not in yet: keys is_gallery and gallery_data to Link | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # 1.390 fixed reply() in Link and Comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # 1.389 docs, fixed get_flair_options. when requesting flair for specific user it always failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # and returned the requsting user's flair instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # 1.388 5/3 added approve and ignore_reports to Comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # Needs doc: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # report, modmail_mute, modmail_action, Modm...->archive, sticky_post | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # 1.387 Added approve and ignore_report functions to Link.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | ▶ | use Data::Dumper qw/Dumper/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | ▶ | use JSON qw/decode_json/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | ▶ | use File::Spec qw//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | ▶ | use Digest::MD5 qw/md5_hex/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | use POSIX qw/strftime/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | #use File::Path::Expand qw//; # Does nothing? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | require Reddit::Client::Account; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | require Reddit::Client::Comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | require Reddit::Client::Link; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | require Reddit::Client::SubReddit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | require Reddit::Client::Request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | require Reddit::Client::Message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | require Reddit::Client::MoreComments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | require Reddit::Client::ModmailConversation; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 5 | require Reddit::Client::ModmailMessage; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # Constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | ▶ | use constant DEFAULT_LIMIT => 25; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 5 | ▶ | use constant VIEW_HOT => ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | ▶ | use constant VIEW_NEW => 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | ▶ | use constant VIEW_CONTROVERSIAL => 'controversial'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | ▶ | use constant VIEW_TOP => 'top'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | ▶ | use constant VIEW_RISING => 'rising'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | ▶ | use constant VIEW_DEFAULT => VIEW_HOT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 5 | ▶ | use constant VOTE_UP => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 5 | ▶ | use constant VOTE_DOWN => -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | ▶ | use constant VOTE_NONE => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | ▶ | use constant SUBMIT_LINK => 'link'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | ▶ | use constant SUBMIT_SELF => 'self'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 5 | ▶ | use constant SUBMIT_MESSAGE => 'message'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 5 | ▶ | use constant SUBMIT_CROSSPOST => 'crosspost'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 5 | ▶ | use constant MESSAGES_INBOX => 'inbox'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | use constant MESSAGES_UNREAD => 'unread'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | ▶ | use constant MESSAGES_SENT => 'sent'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 5 | ▶ | use constant MESSAGES_MESSAGES => 'messages'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | ▶ | use constant MESSAGES_COMMENTREPLIES => 'comments'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | ▶ | use constant MESSAGES_POSTREPLIES => 'selfreply'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | ▶ | use constant MESSAGES_MENTIONS => 'mentions'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | ▶ | use constant SUBREDDITS_HOME => ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | ▶ | use constant SUBREDDITS_MINE => 'subscriber'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | ▶ | use constant SUBREDDITS_POPULAR => 'popular'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 5 | ▶ | use constant SUBREDDITS_NEW => 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 5 | ▶ | use constant SUBREDDITS_CONTRIB => 'contributor'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 5 | ▶ | use constant SUBREDDITS_MOD => 'moderator'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | ▶ | use constant USER_OVERVIEW => 'overview'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 5 | ▶ | use constant USER_COMMENTS => 'comments'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 5 | ▶ | use constant USER_SUBMITTED => 'submitted'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | ▶ | use constant USER_GILDED => 'gilded'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 5 | ▶ | use constant USER_UPVOTED => 'upvoted'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 5 | ▶ | use constant USER_DOWNVOTED => 'downvoted'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | ▶ | use constant USER_HIDDEN => 'hidden'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | ▶ | use constant USER_SAVED => 'saved'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | ▶ | use constant USER_ABOUT => 'about'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | ▶ | use constant API_ME => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | ▶ | use constant API_INFO => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 5 | ▶ | use constant API_SUB_SEARCH => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 5 | ▶ | use constant API_LOGIN => 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 5 | ▶ | use constant API_SUBMIT => 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 5 | ▶ | use constant API_COMMENT => 5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 5 | ▶ | use constant API_VOTE => 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 5 | ▶ | use constant API_SAVE => 7; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 5 | ▶ | use constant API_UNSAVE => 8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 5 | ▶ | use constant API_HIDE => 9; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 5 | ▶ | use constant API_UNHIDE => 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 5 | ▶ | use constant API_SUBREDDITS => 11; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | ▶ | use constant API_LINKS_FRONT => 12; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | ▶ | use constant API_LINKS_OTHER => 13; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | ▶ | use constant API_DEL => 14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 5 | ▶ | use constant API_MESSAGE => 15; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 5 | ▶ | use constant API_COMMENTS_FRONT => 16; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 5 | ▶ | use constant API_COMMENTS => 17; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 5 | ▶ | use constant API_MESSAGES => 18; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 5 | ▶ | use constant API_MARK_READ => 19; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 5 | ▶ | use constant API_MARKALL => 20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 5 | ▶ | use constant API_MY_SUBREDDITS => 21; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 5 | ▶ | use constant API_USER => 22; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 5 | ▶ | use constant API_SELECTFLAIR => 23; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | ▶ | use constant API_FLAIROPTS => 24; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | ▶ | use constant API_EDITWIKI => 25; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 5 | ▶ | use constant API_CREATEMULTI => 26; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 5 | ▶ | use constant API_DELETEMULTI => 27; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 5 | ▶ | use constant API_GETMULTI => 28; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | ▶ | use constant API_EDITMULTI => 29; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | ▶ | use constant API_SUBREDDIT_INFO => 30; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | ▶ | use constant API_SEARCH => 31; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 5 | ▶ | use constant API_MODQ => 32; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 5 | ▶ | use constant API_EDIT => 33; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 5 | ▶ | use constant API_REMOVE => 34; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 5 | ▶ | use constant API_APPROVE => 35; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | ▶ | use constant API_IGNORE_REPORTS => 36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 5 | ▶ | use constant API_GETWIKI => 37; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | ▶ | use constant API_GET_MODMAIL => 38; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 5 | ▶ | use constant API_BAN => 39; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 5 | ▶ | use constant API_MORECHILDREN => 40; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | use constant API_BY_ID => 41; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 5 | ▶ | use constant API_FLAIR => 42; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 5 | ▶ | use constant API_DELETEFLAIR => 43; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | use constant API_UNBAN => 44; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | ▶ | use constant API_DISTINGUISH => 45; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 5 | ▶ | use constant API_UNDISTINGUISH => 46; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 5 | ▶ | use constant API_LOCK => 47; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 5 | ▶ | use constant API_UNLOCK => 48; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 | ▶ | use constant API_MARKNSFW => 49; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 5 | ▶ | use constant API_UNMARKNSFW => 50; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 5 | ▶ | use constant API_FLAIRTEMPLATE2 => 51; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | use constant API_LINKFLAIRV1 => 52; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | ▶ | use constant API_LINKFLAIRV2 => 53; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | ▶ | use constant API_USERFLAIRV1 => 54; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | ▶ | use constant API_USERFLAIRV2 => 55; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 5 | ▶ | use constant API_NEW_MM_CONV => 56; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 5 | ▶ | use constant API_FRIEND => 57; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 5 | ▶ | use constant API_STICKY_POST => 58; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | ▶ | use constant API_MM_MUTE => 59; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | ▶ | use constant API_REPORT => 60; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 5 | ▶ | use constant API_MM_POST_ACTION => 61; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | ▶ | use constant API_MM_GET_ACTION => 62; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | ▶ | use constant API_SUBINFO => 63; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | ▶ | use constant API_ABOUT => 64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5 | ▶ | use constant API_DUPLICATES => 65; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # Parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 5 | our $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 5 | our $BASE_URL = 'https://oauth.reddit.com'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | ▶ | use constant BASE_URL =>'https://oauth.reddit.com'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | our $LINK_URL = 'https://www.reddit.com'; # Why are there two of these? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 | ▶ | use constant LINK_URL =>'https://www.reddit.com'; # both are unused now? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | our @API; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | $API[API_ME ] = ['GET', '/api/v1/me' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | $API[API_INFO ] = ['GET', '/api/info' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | $API[API_SUB_SEARCH ] = ['GET', '/subreddits/search' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | $API[API_LOGIN ] = ['POST', '/api/login/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 5 | $API[API_SUBMIT ] = ['POST', '/api/submit' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5 | $API[API_COMMENT ] = ['POST', '/api/comment' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 5 | $API[API_VOTE ] = ['POST', '/api/vote' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 5 | $API[API_SAVE ] = ['POST', '/api/save' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 5 | $API[API_UNSAVE ] = ['POST', '/api/unsave' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | $API[API_HIDE ] = ['POST', '/api/hide' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 5 | $API[API_UNHIDE ] = ['POST', '/api/unhide' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | $API[API_SUBREDDITS ] = ['GET', '/subreddits/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 5 | $API[API_MY_SUBREDDITS ] = ['GET', '/subreddits/mine/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 5 | $API[API_LINKS_OTHER ] = ['GET', '/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | $API[API_LINKS_FRONT ] = ['GET', '/r/%s/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 5 | $API[API_DEL ] = ['POST', '/api/del' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 5 | $API[API_MESSAGE ] = ['POST', '/api/compose' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5 | $API[API_COMMENTS ] = ['GET', '/r/%s/comments' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 5 | $API[API_COMMENTS_FRONT] = ['GET', '/comments' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5 | $API[API_MESSAGES ] = ['GET', '/message/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | $API[API_MARK_READ ] = ['POST', '/api/read_message' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 5 | $API[API_MARKALL ] = ['POST', '/api/read_all_messages' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | $API[API_USER ] = ['GET', '/user/%s/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | $API[API_SELECTFLAIR ] = ['POST', '/r/%s/api/selectflair' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | $API[API_FLAIROPTS ] = ['POST', '/r/%s/api/flairselector' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 5 | $API[API_EDITWIKI ] = ['POST', '/r/%s/api/wiki/edit' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | $API[API_GETWIKI ] = ['GET', '/r/%s/wiki/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 5 | $API[API_CREATEMULTI ] = ['POST', '/api/multi/user/%s/m/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 5 | $API[API_GETMULTI ] = ['GET', '/api/multi/user/%s/m/%s%s']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | $API[API_DELETEMULTI ] = ['DELETE','/api/multi/user/%s/m/%s']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 5 | $API[API_EDITMULTI ] = ['PUT', '/api/multi/user/%s/m/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | $API[API_ABOUT ] = ['GET', '/r/%s/about' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 5 | $API[API_SUBINFO ] = ['GET', '/r/%s/about/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 5 | $API[API_SEARCH ] = ['GET', '/r/%s/search' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | $API[API_MODQ ] = ['GET', '/r/%s/about/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 5 | $API[API_EDIT ] = ['POST', '/api/editusertext' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | $API[API_REMOVE ] = ['POST', '/api/remove' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 5 | $API[API_APPROVE ] = ['POST', '/api/approve' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 5 | $API[API_IGNORE_REPORTS] = ['POST', '/api/ignore_reports' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 5 | $API[API_GET_MODMAIL ] = ['GET', '/api/mod/conversations' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 5 | $API[API_BAN ] = ['POST', '/r/%s/api/friend' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 5 | $API[API_MORECHILDREN ] = ['GET', '/api/morechildren' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 5 | $API[API_BY_ID ] = ['GET', '/by_id' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 5 | $API[API_FLAIR ] = ['POST', '/r/%s/api/flair' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | $API[API_DELETEFLAIR ] = ['POST', '/r/%s/api/deleteflair' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | $API[API_UNBAN ] = ['POST', '/r/%s/api/unfriend' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 5 | $API[API_DISTINGUISH ] = ['POST', '/api/distinguish' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | $API[API_UNDISTINGUISH ] = ['POST', '/api/distinguish' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 5 | $API[API_LOCK ] = ['POST', '/api/lock' ]; # fullname | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 5 | $API[API_UNLOCK ] = ['POST', '/api/unlock' ]; # only | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | $API[API_MARKNSFW ] = ['POST', '/api/marknsfw' ]; # these | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | $API[API_UNMARKNSFW ] = ['POST', '/api/unmarknsfw' ]; # four | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | $API[API_FLAIRTEMPLATE2] = ['POST', '/r/%s/api/flairtemplate_v2']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 5 | $API[API_LINKFLAIRV1 ] = ['GET', '/r/%s/api/link_flair' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 5 | $API[API_LINKFLAIRV2 ] = ['GET', '/r/%s/api/link_flair_v2' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 5 | $API[API_USERFLAIRV1 ] = ['GET', '/r/%s/api/user_flair' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 5 | $API[API_USERFLAIRV2 ] = ['GET', '/r/%s/api/user_flair_v2' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # Read modmail conversation uses GET on the same endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 5 | $API[API_NEW_MM_CONV ] = ['POST', '/api/mod/conversations' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 5 | $API[API_FRIEND ] = ['PUT', '/api/v1/me/friends/%' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 5 | $API[API_STICKY_POST ] = ['POST', '/api/set_subreddit_sticky']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 5 | $API[API_MM_MUTE ] = ['POST', '/api/mod/conversations/%s/mute']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 5 | $API[API_REPORT ] = ['POST', '/api/report' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 5 | $API[API_MM_POST_ACTION] = ['POST', '/api/mod/conversations/%s/%s']; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 5 | $API[API_DUPLICATES ] = ['GET', '/duplicates/%s' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | #POST /api/mod/conversations/:conversation_id/mute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | #conversation_id base36 modmail conversation id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # Class methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 5 | ▶ | use fields ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 5 | 'modhash', # No longer used. stored session modhash | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 'cookie', # No longer used. stored user cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 'session_file', # No longer used. path to session file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 'user_agent', # user agent string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 'token', # oauth authorization token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 'tokentype', # unused but saved for reference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 'last_token', # time last token was acquired | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 'client_id', # always required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 'secret', # always required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 'username', # now optional for web apps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 'password', # script apps only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 'request_errors', # print request errors, deprecated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 'print_request_errors', # print request errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 'print_response', # print response content, deprecated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 'print_response_content',# print response content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 'print_request', # print entire request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 'print_request_on_error',# print entire request on error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 'refresh_token', # oauth refresh token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 'auth_type', # 'script' or 'webapp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 'debug', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 'subdomain', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=20 SCAR=60.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my ($class, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $self = fields::new($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (not exists $param{user_agent}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | croak "param 'user_agent' is required."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $self->{user_agent} = $param{user_agent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # request_errors does nothing? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | $self->{request_errors} = $param{print_request_errors} || $param{request_errors} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'print_request_errors'} || $param{'request_errors'} || 0
$param{"print_request_errors"} or $param{"request_errors"}
MC/DC0%0/2
$param{'print_request_errors'} || $param{'request_errors'} || 0
$param{"print_request_errors"}
$param{"request_errors"}
Truth table0%0/3
A or B
A= $param{"print_request_errors"}B= $param{"request_errors"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | $self->{print_response} = $param{print_response} || $param{print_response_conent} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'print_response'} || $param{'print_response_conent'} || 0
$param{"print_response"} or $param{"print_response_conent"}
MC/DC0%0/2
$param{'print_response'} || $param{'print_response_conent'} || 0
$param{"print_response"}
$param{"print_response_conent"}
Truth table0%0/3
A or B
A= $param{"print_response"}B= $param{"print_response_conent"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $self->{print_request} = $param{print_request} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'print_request'} || 0
MC/DC0%0/1
$param{'print_request'} || 0
$param{'print_request'}
Truth table0%0/2
A
A= $param{'print_request'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | $self->{debug} = $param{debug} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'debug'} || 0
MC/DC0%0/1
$param{'debug'} || 0
$param{'debug'}
Truth table0%0/2
A
A= $param{'debug'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | $self->{print_request_on_error} = $param{print_request_on_error} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'print_request_on_error'} || 0
MC/DC0%0/1
$param{'print_request_on_error'} || 0
$param{'print_request_on_error'}
Truth table0%0/2
A
A= $param{'print_request_on_error'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | $self->{subdomain} = $param{subdomain} || 'www'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'subdomain'} || 'www'
MC/DC0%0/1
$param{'subdomain'} || 'www'
$param{'subdomain'}
Truth table0%0/2
A
A= $param{'subdomain'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ($param{password}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if (!$param{username}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | croak "if password is provided, username is required."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ▶ | } elsif (!$param{client_id} or !$param{secret}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$param{'client_id'} && $param{'secret'}
MC/DC0%0/2
$param{'client_id'} && $param{'secret'}
$param{'client_id'}
$param{'secret'}
Truth table0%0/3
A && B
A= $param{'client_id'}B= $param{'secret'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | croak "client_id and secret are required for authorized apps."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $self->{auth_type} = 'script'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $self->{client_id} = $param{client_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $self->{secret} = $param{secret}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->{username} = $param{username}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $self->{password} = $param{password}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $self->get_token(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } elsif ($param{refresh_token}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | croak "client_id and secret are required for authorized apps." unless $param{client_id} and $param{secret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$param{"client_id"} and $param{"secret"}
MC/DC0%0/2
$param{"client_id"} and $param{"secret"}
$param{"client_id"}
$param{"secret"}
Truth table0%0/3
A and B
A= $param{"client_id"}B= $param{"secret"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $self->{auth_type} = 'webapp'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $self->{client_id} = $param{client_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $self->{secret} = $param{secret}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $self->{refresh_token}= $param{refresh_token}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # will this break anything? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $self->{username} = $param{username} if $param{username}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self->get_token(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | # optionall allow people to pass in client id and secret now, for people | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # who choose to get refresh token from an RC object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $self->{client_id} = $param{client_id} if $param{client_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | $self->{secret} = $param{secret} if $param{secret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # can this even be run without auth anymore? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $self->{auth_type} = 'none'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | return $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # Requests and Oauth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my ($self, $method, $path, $query, $post_data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # 401s not being caused by this. they are a new API issue apparently. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if (!$self->{last_token} or $self->{last_token} <= ( time - 3600 + 55) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->{"last_token"} or $self->{"last_token"} <= time - 3600 + 55
MC/DC0%0/2
not $self->{"last_token"} or $self->{"last_token"} <= time - 3600 + 55
not $self->{"last_token"}
$self->{"last_token"} <= time - 3600 + 55
Truth table0%0/3
not(A) or B
A= not $self->{"last_token"}B= $self->{"last_token"} <= time - 3600 + 55
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # passing in username, pass, client_id, secret here did nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $self->get_token(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # Trim leading slashes off of the path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $path =~ s/^\/+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | my $request = Reddit::Client::Request->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | user_agent => $self->{user_agent}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # path is sprintf'd before call, in api_json_request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # the calling function passes in path %s's in 'args' param | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | url => sprintf('%s/%s', $BASE_URL, $path), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | method => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | query => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | post_data => $post_data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | modhash => $self->{modhash}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | cookie => $self->{cookie}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | token => $self->{token}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | tokentype => $self->{tokentype}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | last_token => $self->{last_token}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | request_errors=> $self->{request_errors}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | print_response=> $self->{print_response}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | print_request=> $self->{print_request}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | print_request_on_error=>$self->{print_request_on_error}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return $request->send; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub get_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_token: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # let people set auth things here. this was stupid to allow. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # these all set $self properties then continue as normal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if ($param{username} or $param{password}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$param{"username"} or $param{"password"}
MC/DC0%0/2
$param{"username"} or $param{"password"}
$param{"username"}
$param{"password"}
Truth table0%0/3
A or B
A= $param{"username"}B= $param{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | die "get_token: if username or password are provided, all 4 script-type authentication arguments (username, password, client_id, secret) are required." unless $param{username} and $param{password} and $param{client_id} and $param{secret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$param{"username"} and $param{"password"} and $param{"client_id"} and $param{"secret"}
$param{"username"} and $param{"password"} and $param{"client_id"}
$param{"username"} and $param{"password"}
MC/DC0%0/4
$param{"username"} and $param{"password"} and $param{"client_id"} and $param{"secret"}
$param{"username"}
$param{"password"}
$param{"client_id"}
$param{"secret"}
Truth table0%0/5
A and B and C and D
A= $param{"username"}B= $param{"password"}C= $param{"client_id"}D= $param{"secret"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $self->{auth_type} = 'script'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $self->{client_id} = $param{client_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $self->{secret} = $param{secret}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->{username} = $param{username}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $self->{password} = $param{password}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } elsif ($param{refresh_token}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $self->{auth_type} = 'webapp'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $self->{client_id} = $param{client_id} || $self->{client_id} || die "get_token: 'client_id' must be set, either as a parameter to get_token or when instantiating the Reddit::Client object."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'client_id'} || $self->{'client_id'} || die(q[get_token: 'client_id' must be set, either as a parameter to get_token or when instantiating the Reddit::Client object.])
$param{"client_id"} or $self->{"client_id"}
MC/DC0%0/2
$param{'client_id'} || $self->{'client_id'} || die(q[get_token: 'client_id' must be set, either as a parameter to get_token or when instantiating the Reddit::Client object.])
$param{"client_id"}
$self->{"client_id"}
Truth table0%0/3
A or B
A= $param{"client_id"}B= $self->{"client_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | $self->{secret} = $param{secret} || $self->{secret} || die "get_token: 'secret' must be set, either as a parameter to get_token or when instantiating the Reddit::Client object."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'secret'} || $self->{'secret'} || die(q[get_token: 'secret' must be set, either as a parameter to get_token or when instantiating the Reddit::Client object.])
$param{"secret"} or $self->{"secret"}
MC/DC0%0/2
$param{'secret'} || $self->{'secret'} || die(q[get_token: 'secret' must be set, either as a parameter to get_token or when instantiating the Reddit::Client object.])
$param{"secret"}
$self->{"secret"}
Truth table0%0/3
A or B
A= $param{"secret"}B= $self->{"secret"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $self->{refresh_token} = $param{refresh_token}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $self->{last_token} = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # why don't we just pass in the whole Client object ffs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | my %p = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | client_id => $self->{client_id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | secret => $self->{secret}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | user_agent => $self->{user_agent}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | auth_type => $self->{auth_type}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | if ($self->{auth_type} eq 'script') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | $p{username} = $self->{username}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | $p{password} = $self->{password}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | } elsif ($self->{auth_type} eq 'webapp') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $p{refresh_token} = $self->{refresh_token}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | } else { die "get_token: invalid auth type"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # Why is this static? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $message = Reddit::Client::Request->token_request(%p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $j = decode_json($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $self->{token} = $j->{access_token}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | $self->{tokentype} = $j->{token_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if (!$self->{token}) { croak "Unable to get or parse token."; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | sub has_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_token: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | return (!$self->{last_token} || $self->{last_token} <= time - 3595) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->{"last_token"} or $self->{"last_token"} <= time - 3595
MC/DC0%0/2
not $self->{"last_token"} or $self->{"last_token"} <= time - 3595
not $self->{"last_token"}
$self->{"last_token"} <= time - 3595
Truth table0%0/3
not(A) or B
A= not $self->{"last_token"}B= $self->{"last_token"} <= time - 3595
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # This must be called in static context because no refresh token or user/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # pass combination exist. We would have to add a third flow and that doesn't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # seem worth it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # We could call it in an empty RC object, but that would require all sorts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # of annoyoing conditions, and all other methods would be broken until | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # tokens were obtained | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub get_refresh_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_refresh_token: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my %data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | $data{code} = $param{code} || die "'code' is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'code'} || die("'code' is required.\n")
MC/DC0%0/1
$param{'code'} || die("'code' is required.\n")
$param{'code'}
Truth table0%0/2
A
A= $param{'code'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | $data{redirect_uri} = $param{redirect_uri} || die "'redirect_uri' is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'redirect_uri'} || die("'redirect_uri' is required.\n")
MC/DC0%0/1
$param{'redirect_uri'} || die("'redirect_uri' is required.\n")
$param{'redirect_uri'}
Truth table0%0/2
A
A= $param{'redirect_uri'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | $data{client_id} = (ref $self eq 'HASH' and $self->{client_id} ? $self->{client_id} : undef) || $param{client_id} || die "'client_id' is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
ref $self eq 'HASH' && ($self->{'client_id'} ? $self->{'client_id'} : undef) || $param{'client_id'} || die("'client_id' is required.\n")
ref $self eq "HASH" and $self->{"client_id"} ? $self->{"client_id"} : undef or $param{"client_id"}
ref $self eq "HASH" and $self->{"client_id"} ? $self->{"client_id"} : undef
MC/DC0%0/3
ref $self eq 'HASH' && ($self->{'client_id'} ? $self->{'client_id'} : undef) || $param{'client_id'} || die("'client_id' is required.\n")
ref $self eq "HASH"
$self->{"client_id"} ? $self->{"client_id"} : undef
$param{"client_id"}
Truth table0%0/5
A and B or C
A= ref $self eq "HASH"B= $self->{"client_id"} ? $self->{"client_id"} : undefC= $param{"client_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | $data{secret} = (ref $self eq 'HASH' and $self->{secret} ? $self->{secret} : undef) || $param{secret} || die "'secret' is required."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
ref $self eq 'HASH' && ($self->{'secret'} ? $self->{'secret'} : undef) || $param{'secret'} || die(q['secret' is required.])
ref $self eq "HASH" and $self->{"secret"} ? $self->{"secret"} : undef or $param{"secret"}
ref $self eq "HASH" and $self->{"secret"} ? $self->{"secret"} : undef
MC/DC0%0/3
ref $self eq 'HASH' && ($self->{'secret'} ? $self->{'secret'} : undef) || $param{'secret'} || die(q['secret' is required.])
ref $self eq "HASH"
$self->{"secret"} ? $self->{"secret"} : undef
$param{"secret"}
Truth table0%0/5
A and B or C
A= ref $self eq "HASH"B= $self->{"secret"} ? $self->{"secret"} : undefC= $param{"secret"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | $data{ua} = (ref $self eq 'HASH' and $self->{user_agent} ? $self->{user_agent} : undef) || $param{user_agent} || die "'user_agent' is required."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
ref $self eq 'HASH' && ($self->{'user_agent'} ? $self->{'user_agent'} : undef) || $param{'user_agent'} || die(q['user_agent' is required.])
ref $self eq "HASH" and $self->{"user_agent"} ? $self->{"user_agent"} : undef or $param{"user_agent"}
ref $self eq "HASH" and $self->{"user_agent"} ? $self->{"user_agent"} : undef
MC/DC0%0/3
ref $self eq 'HASH' && ($self->{'user_agent'} ? $self->{'user_agent'} : undef) || $param{'user_agent'} || die(q['user_agent' is required.])
ref $self eq "HASH"
$self->{"user_agent"} ? $self->{"user_agent"} : undef
$param{"user_agent"}
Truth table0%0/5
A and B or C
A= ref $self eq "HASH"B= $self->{"user_agent"} ? $self->{"user_agent"} : undefC= $param{"user_agent"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | #$data{ua} = $param{user_agent} || die "user_agent is required"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $data{grant_type} = 'authorization_code'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $data{duration} = 'permanent'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $refresh_token = Reddit::Client::Request->refresh_token_request(%data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | return $refresh_token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub json_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
json_request: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my ($self, $method, $path, $query, $post_data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | DEBUG('%4s JSON', $method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | if ($method eq 'POST') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | $post_data ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$post_data ||= {}
MC/DC0%0/1
$post_data ||= {}
$post_data
Truth table0%0/2
A
A= $post_data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $post_data->{api_type} = 'json'; # only POST enpoints require* | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | #$path .= '.json'; # the oauth api returns json by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $response = $self->request($method, $path, $query, $post_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | my $json = JSON::from_json($response) if $response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if (ref $json eq 'HASH' && $json->{json}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $json eq "HASH" and $json->{"json"}
MC/DC0%0/2
ref $json eq "HASH" and $json->{"json"}
ref $json eq "HASH"
$json->{"json"}
Truth table0%0/3
A and B
A= ref $json eq "HASH"B= $json->{"json"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my $result = $json->{json}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if (@{$result->{errors}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | DEBUG('API Errors: %s', Dumper($result->{errors})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | my @errors = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | sprintf '[%s] %s', $_->[0], $_->[1] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | } @{$result->{errors}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | croak sprintf("Error(s): %s", join('|', @errors)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | return $json; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | sub api_json_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
api_json_request: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | my $args = $param{args} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'args'} || []
MC/DC0%0/1
$param{'args'} || []
$param{'args'}
Truth table0%0/2
A
A= $param{'args'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my $api = $param{api}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $data = $param{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my $callback = $param{callback}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | croak 'Expected "api"' unless defined $api; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | DEBUG('API call %d', $api); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | my $info = $API[$api] || croak "Unknown API: $api"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Reddit::Client::API[$api] || croak("Unknown API: $api")
MC/DC0%0/1
$Reddit::Client::API[$api] || croak("Unknown API: $api")
$Reddit::Client::API[$api]
Truth table0%0/2
A
A= $Reddit::Client::API[$api]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my ($method, $path) = @$info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $path = sprintf $path, @$args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | my ($query, $post_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | if ($method eq 'GET' or $method eq 'DELETE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$method eq "GET" or $method eq "DELETE"
MC/DC0%0/2
$method eq "GET" or $method eq "DELETE"
$method eq "GET"
$method eq "DELETE"
Truth table0%0/3
A or B
A= $method eq "GET"B= $method eq "DELETE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $query = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | $post_data = $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my $result = $self->json_request($method, $path, $query, $post_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # This breaks on endpoints that return an array like flairselect v2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | if (ref $result eq 'HASH' and exists $result->{errors}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $result eq "HASH" and exists $result->{"errors"}
MC/DC0%0/2
ref $result eq "HASH" and exists $result->{"errors"}
ref $result eq "HASH"
exists $result->{"errors"}
Truth table0%0/3
A and B
A= ref $result eq "HASH"B= exists $result->{"errors"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my @errors = @{$result->{errors}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if (@errors) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | DEBUG("ERRORS: @errors"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $message = join(' | ', map { join(', ', @$_) } @errors); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | croak $message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # The fuck is this? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | if (defined $callback && ref $callback eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $callback and ref $callback eq "CODE"
MC/DC0%0/2
defined $callback and ref $callback eq "CODE"
defined $callback
ref $callback eq "CODE"
Truth table0%0/3
A and B
A= defined $callbackB= ref $callback eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | return $callback->($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # deprecated, to be removed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | sub is_logged_in { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_logged_in: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | return defined $_[0]->{modhash}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # deprecated, to be removed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | sub require_login { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_login: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # User and account management | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | sub me { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
me: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | DEBUG('Request user account info'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $result = $self->api_json_request(api => API_ME); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # Account has no data property like other things | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | return Reddit::Client::Account->new($self, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | sub list_subreddits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_subreddits: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | my $type = $param{view} || SUBREDDITS_HOME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'view'} || ''
MC/DC0%0/1
$param{'view'} || ''
$param{'view'}
Truth table0%0/2
A
A= $param{'view'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | $type = '' if lc $type eq 'home'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | my $query = $self->set_listing_defaults(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | my $api = $type eq SUBREDDITS_MOD || $type eq SUBREDDITS_CONTRIB || $type eq SUBREDDITS_MINE ? API_MY_SUBREDDITS : API_SUBREDDITS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$type eq "moderator" or $type eq "contributor" or $type eq "subscriber"
$type eq "moderator" or $type eq "contributor"
MC/DC0%0/3
$type eq "moderator" or $type eq "contributor" or $type eq "subscriber"
$type eq "moderator"
$type eq "contributor"
$type eq "subscriber"
Truth table0%0/4
A or B or C
A= $type eq "moderator"B= $type eq "contributor"C= $type eq "subscriber"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | api => $api, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | args => [$type], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | data => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | map {Reddit::Client::SubReddit->new($self, $_->{data})} @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | sub contrib_subreddits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contrib_subreddits: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $param{view} = SUBREDDITS_CONTRIB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | return $_[0]->list_subreddits(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | sub home_subreddits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
home_subreddits: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $param{view} = SUBREDDITS_HOME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | return $_[0]->list_subreddits(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | sub mod_subreddits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mod_subreddits: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $param{view} = SUBREDDITS_MOD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | return $_[0]->list_subreddits(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | sub my_subreddits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
my_subreddits: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $param{view} = SUBREDDITS_MINE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | return $_[0]->list_subreddits(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | sub new_subreddits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_subreddits: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $param{view} = SUBREDDITS_NEW; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | return $_[0]->list_subreddits(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | sub popular_subreddits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
popular_subreddits: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | $param{view} = SUBREDDITS_POPULAR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | return $_[0]->list_subreddits(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # Inbox and messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | sub get_inbox { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_inbox: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | my $limit = $param{limit} || DEFAULT_LIMIT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'limit'} || 25
MC/DC0%0/1
$param{'limit'} || 25
$param{'limit'}
Truth table0%0/2
A
A= $param{'limit'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | my $mode = $param{mode} || MESSAGES_INBOX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'mode'} || 'inbox'
MC/DC0%0/1
$param{'mode'} || 'inbox'
$param{'mode'}
Truth table0%0/2
A
A= $param{'mode'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | my $view = $param{view} || MESSAGES_INBOX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'view'} || 'inbox'
MC/DC0%0/1
$param{'view'} || 'inbox'
$param{'view'}
Truth table0%0/2
A
A= $param{'view'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | # this before and after business is stupid and needs to be fixed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | # in 3 separate places | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $query = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | $query->{mark} = $param{mark} ? 'true' : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | $query->{sr_detail} = $param{sr_detail} if $param{sr_detail}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | $query->{before} = $param{before} if $param{before}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | $query->{after} = $param{after} if $param{after}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if (exists $param{limit}) { $query->{limit} = $param{limit} || 500; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$param{'limit'} || 500
MC/DC0%0/1
$param{'limit'} || 500
$param{'limit'}
Truth table0%0/2
A
A= $param{'limit'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | else { $query->{limit} = DEFAULT_LIMIT; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | api => API_MESSAGES, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | args => [$view], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | data => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | #return $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | map { Reddit::Client::Message->new($self, $_->{data}) } @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | # TODO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | sub mark_read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_read: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | sub mark_inbox_read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_inbox_read: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my ($method, $path) = @{$API[API_MARKALL]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # Why does this error without api_type? json_request is adding it anyway? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my $post_data = {api_type => 'json'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $result = $self->request($method, $path, {}, $post_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | # Subreddits and listings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # works section 1: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | # banned, muted, wikibanned, contributors, wikicontributors, moderators, edit, log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | # should work but returns undef: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # rules (uses read), traffic (uses modconfig), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | sub get_subreddit_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_subreddit_info: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | my $sub = shift || croak 'Argument 1 (subreddit name) is required.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || croak('Argument 1 (subreddit name) is required.')
MC/DC0%0/1
shift() || croak('Argument 1 (subreddit name) is required.')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | $sub = subreddit($sub); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my $page = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | my ($api, $args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | if ($page) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | $api = API_SUBINFO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | $args = [$sub, $page]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | $api = API_ABOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | $args = [$sub]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | api => $api, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | #return $result->{data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | sub info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
info: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | my ($self, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | defined $id || croak 'Expected $id'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $query->{id} = $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $info = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | api => API_INFO, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | data=>$query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | #return $info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | my $rtn = $info->{data}->{children}[0]->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | $rtn->{kind} = $info->{data}->{children}[0]->{kind} if $rtn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | return $rtn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | sub search { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | my $sub = $param{subreddit} || $param{sub} || croak "'subreddit' or 'sub' is required."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'subreddit'} || $param{'sub'} || croak(q['subreddit' or 'sub' is required.])
$param{"subreddit"} or $param{"sub"}
MC/DC0%0/2
$param{'subreddit'} || $param{'sub'} || croak(q['subreddit' or 'sub' is required.])
$param{"subreddit"}
$param{"sub"}
Truth table0%0/3
A or B
A= $param{"subreddit"}B= $param{"sub"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $query = $self->set_listing_defaults(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | $query->{q} = $param{q} || croak "'q' (search string) is required."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'q'} || croak(q['q' (search string) is required.])
MC/DC0%0/1
$param{'q'} || croak(q['q' (search string) is required.])
$param{'q'}
Truth table0%0/2
A
A= $param{'q'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # things the user should be able to choose but we're hard coding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | $query->{restrict_sr} = 'on'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $query->{include_over18}= 'on'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | $query->{t} = 'all'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | $query->{syntax} = 'cloudsearch'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | $query->{show} = 'all'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | $query->{type} = 'link'; # return Link objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $query->{sort} = 'top'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | my $args = [$sub]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | api => API_SEARCH, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | args=> $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | data => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | #return $result->{data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | map {Reddit::Client::Link->new($self, $_->{data})} @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | sub get_permalink { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_permalink: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | # This still makes an extra request. Why? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | my ($self, $commentid, $post_fullname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | if (substr ($commentid, 0, 3) eq "t1_") { $commentid = substr $commentid, 3; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | if (substr ($post_fullname, 0, 3) ne "t3_") { $post_fullname = "t3_" . $post_fullname; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | my $info = $self->info($post_fullname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | return sprintf "%s%s%s", $LINK_URL, $info->{permalink}, $commentid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | sub find_subreddits { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_subreddits: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my $query = $self->set_listing_defaults(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | $query->{q} = $param{q} || croak "expected 'q'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'q'} || croak(q[expected 'q'])
MC/DC0%0/1
$param{'q'} || croak(q[expected 'q'])
$param{'q'}
Truth table0%0/2
A
A= $param{'q'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | $query->{sort} = $param{sort} || 'relevance'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'sort'} || 'relevance'
MC/DC0%0/1
$param{'sort'} || 'relevance'
$param{'sort'}
Truth table0%0/2
A
A= $param{'sort'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | api => API_SUB_SEARCH, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | data => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | map { Reddit::Client::SubReddit->new($self, $_->{data}) } @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | # should first arg be id? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | sub duplicates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
duplicates: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my ($self, $id, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | $id = id($id); # strip permalink code if it exists | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my $query = $self->set_listing_defaults(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | $query->{crossposts_only} = $param{crossposts_only} ? 'true' : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $query->{sort} = 'num_comments'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | $query->{sort} = $param{sort} if $param{sort}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | $query->{sr} = $param{subreddit}||$param{sub} if $param{subreddit}||$param{sub}; # optional? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$param{"subreddit"} or $param{"sub"}
$param{'subreddit'} || $param{'sub'}
MC/DC0%0/2
$param{"subreddit"} or $param{"sub"}
$param{"subreddit"}
$param{"sub"}
MC/DC0%0/2
$param{'subreddit'} || $param{'sub'}
$param{'subreddit'}
$param{'sub'}
Truth table0%0/3
A or B
A= $param{"subreddit"}B= $param{"sub"}
Truth table0%0/3
A || B
A= $param{'subreddit'}B= $param{'sub'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $query->{article} = $id; # specification has it both in URL and here, /shrug | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | my $args = [$id]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | api => API_DUPLICATES, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | data => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # Reddit returns two listings: a listing with a single element of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | # requested post, and a second listing with the matches. Reddit::Client only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | # returns the second listing, assuming the user already has the first or can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | # access it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | map { Reddit::Client::Link->new($self, $_->{data}) } @{$$result[1]{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | sub fetch_links { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_links: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | my $subreddit = $param{sub} || $param{subreddit} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || ''
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || ''
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | my $view = $param{view}|| VIEW_DEFAULT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'view'} || ''
MC/DC0%0/1
$param{'view'} || ''
$param{'view'}
Truth table0%0/2
A
A= $param{'view'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | my $query = $self->set_listing_defaults(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | $subreddit = subreddit($subreddit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my $args = [$view]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | unshift @$args, $subreddit if $subreddit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | #$API[API_LINKS_OTHER ] = ['GET', '/%s' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | #$API[API_LINKS_FRONT ] = ['GET', '/r/%s/%s' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | # this is backwards? front is actually a specific sub, other is front page | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | my $result = $self->api_json_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | api => ($subreddit ? API_LINKS_FRONT : API_LINKS_OTHER), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | data => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | #return $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | map { Reddit::Client::Link->new($self, $_->{data}) } @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | sub get_links { # alias for fetch_links to make naming convention consistent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_links: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | return $self->fetch_links(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | # Is this a better way to get a single link than a call to info? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | sub get_links_by_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_links_by_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | my ($self, @fullnames) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | die "get_links_by_id: argument 1 (\@fullnames) is required.\n" unless @fullnames; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | @fullnames = map { fullname($_, 't3') } @fullnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my $str = join ",", @fullnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | # what the fuck is this? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | my $result = $self->json_request('GET', $API[API_BY_ID][1]."/$str"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | map { Reddit::Client::Link->new($self, $_->{data}) } @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | sub get_link { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_link: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | my ($self, $fullname) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | die "get_link: need arg 1 (id/fullname)" unless $fullname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $fullname = fullname($fullname, 't3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | my $result = $self->json_request('GET', $API[API_BY_ID][1]."/$fullname"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | # empty return is caused by purged post, not error on our part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | return Reddit::Client::Link->new($self, $result->{data}{children}[0]{data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | sub get_comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_comment: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | my ($self, $fullname, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | croak "expected argument 1: id or fullname" unless $fullname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | $fullname = fullname($fullname, 't1'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my $info = $self->info($fullname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | return unless $info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | my $cmt = Reddit::Client::Comment->new($self, $info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | if ($param{include_children} and $cmt->{permalink}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$param{"include_children"} and $cmt->{"permalink"}
MC/DC0%0/2
$param{"include_children"} and $cmt->{"permalink"}
$param{"include_children"}
$cmt->{"permalink"}
Truth table0%0/3
A and B
A= $param{"include_children"}B= $cmt->{"permalink"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | $cmt = $self->get_comments(permalink=>$cmt->{permalink}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | $cmt = $$cmt[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | return $cmt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | ▶ | sub get_subreddit_comments { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_subreddit_comments: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | my $subreddit = $param{sub} || $param{subreddit} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || ''
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || ''
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | my $view = $param{view} || VIEW_DEFAULT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'view'} || ''
MC/DC0%0/1
$param{'view'} || ''
$param{'view'}
Truth table0%0/2
A
A= $param{'view'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | my $query = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | $query->{before} = $param{before} if $param{before}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | $query->{after} = $param{after} if $param{after}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | if (exists $param{limit}) { $query->{limit} = $param{limit} || 500; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$param{'limit'} || 500
MC/DC0%0/1
$param{'limit'} || 500
$param{'limit'}
Truth table0%0/2
A
A= $param{'limit'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | else { $query->{limit} = DEFAULT_LIMIT; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | $subreddit = subreddit($subreddit); # remove slashes and leading r/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | my $args = $subreddit ? [$subreddit] : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | ▶ | my $result = $self->api_json_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | api => ($subreddit ? API_COMMENTS : API_COMMENTS_FRONT), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | data => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | #return $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | #return $result->{data}{children}[0]->{data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | map {Reddit::Client::Comment->new($self, $_->{data})} @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | #============================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | # Moderation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | #============================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | my $fullname = shift || die "remove: arg 1 (fullname) is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die("remove: arg 1 (fullname) is required.\n")
MC/DC0%0/1
shift() || die("remove: arg 1 (fullname) is required.\n")
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | api => API_REMOVE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | data => { id => $fullname, spam=> 'false' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | # like remove, but sets spam flag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | sub spam { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spam: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | my $fullname = shift || croak "spam: arg 1 (fullname) is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || croak("spam: arg 1 (fullname) is required.\n")
MC/DC0%0/1
shift() || croak("spam: arg 1 (fullname) is required.\n")
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | api => API_REMOVE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | data => { id => $fullname, spam => 'true' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | ▶ | sub approve { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
approve: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | my $fullname = shift || die "approve: arg 1 (fullname) is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die("approve: arg 1 (fullname) is required.\n")
MC/DC0%0/1
shift() || die("approve: arg 1 (fullname) is required.\n")
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | api => API_APPROVE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | data => { id => $fullname }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | sub ignore_reports { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ignore_reports: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | my $fullname = shift || die "ignore_reports: arg 1 (fullname) is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die("ignore_reports: arg 1 (fullname) is required.\n")
MC/DC0%0/1
shift() || die("ignore_reports: arg 1 (fullname) is required.\n")
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | api => API_IGNORE_REPORTS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | data => { id => $fullname }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | sub lock { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lock: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | my ($self, $fullname, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | die "lock: arg 1 (fullname) is required.\n" unless $fullname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | if (!ispost($fullname) and !iscomment($fullname)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ispost($fullname) or iscomment($fullname)
MC/DC0%0/2
ispost($fullname) or iscomment($fullname)
ispost($fullname)
iscomment($fullname)
Truth table0%0/3
A or B
A= ispost($fullname)B= iscomment($fullname)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | die "lock: arg 1 must be a fullname of a post or comment.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | ▶ | my $lock = exists $param{lock} ? $param{lock} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ▶ | my $result = $self->api_json_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | api => $lock ? API_LOCK : API_UNLOCK, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | data => { id => $fullname }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | sub unlock { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlock: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | my ($self, $fullname, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | return $self->lock($fullname, lock=>0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | ▶ | sub nsfw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nsfw: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | my ($self, $fullname, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | ▶ | die "nsfw: arg 1 (fullname) is required.\n" unless $fullname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | if (!ispost($fullname)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | die "nsfw: arg 1 must be a fullname of a post or comment.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | my $nsfw = exists $param{nsfw} ? $param{nsfw} : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | my $result = $self->api_json_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | api => $nsfw ? API_MARKNSFW : API_UNMARKNSFW, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | data => { id => $fullname }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | ▶ | sub unnsfw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unnsfw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | my ($self, $fullname, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | return $self->nsfw($fullname, nsfw=>0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | # -ban is really a call to friend, which creates relationships between accounts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | # other functions can call it and pass in a different mode (see functions below) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | # this is to make it just as unreadable as Reddit's endpoint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | # TODO: make this a general fn, call ban from outside like modinvite is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | # -ban uses the "modcontributors" oauth scope EXCEPT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | # -moderator and moderator_invite use "modothers" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | # -wikibanned and wikicontributor require both modcontributors and modwiki | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | # https://old.reddit.com/dev/api/#POST_api_friend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | sub ban { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ban: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit} || die "subreddit is required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || die("subreddit is required\n")
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || die("subreddit is required\n")
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | $data->{name} = $param{user} || $param{username} || die "username is required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'user'} || $param{'username'} || die("username is required\n")
$param{"user"} or $param{"username"}
MC/DC0%0/2
$param{'user'} || $param{'username'} || die("username is required\n")
$param{"user"}
$param{"username"}
Truth table0%0/3
A or B
A= $param{"user"}B= $param{"username"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | # ban_context = fullname (of what?) - not required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | # Ban message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | $data->{ban_message} = $param{ban_message} if $param{ban_message}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | # Reason: short report reason | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | if ($param{reason}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | if (length $param{reason} > 100) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | print "Warning: 'reason' longer than 100 characters. Truncating.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | $param{reason} = substr $param{reason}, 0, 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | $data->{ban_reason} = $param{reason}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | if ($param{note}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | if (length $param{note} > 300) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | print "Warning: 'note' longer than 300 characters. Truncating.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 0 | $param{note} = substr $param{note}, 0, 300; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | $data->{note} = $param{note}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | if ($param{duration}){ # if 0 this never even hits which we want anyway | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | if ($param{duration} > 999) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | print "Warning: Max duration is 999. Setting to 999.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | $param{duration} = 999; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } elsif ($param{duration} < 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | $param{duration} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | ▶ | $data->{duration} = $param{duration} if $param{duration}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | # $data->{container} is not needed unless mode is friend or enemy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | # from docs for unfriend https://old.reddit.com/dev/api/#POST_api_unfriend: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | # The user can either be passed in by name (nuser) or by fullname (iuser). If type is friend or enemy, 'container' MUST be the current user's fullname; for other types, the subreddit must be set via URL (e.g., /r/funny/api/unfriend) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | # So what would the arg be? /r/<sub>/api/friend? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | # Unfriend has its own endpoint too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | # $data->{permissions} = ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | # type is one of (friend, moderator, moderator_invite, contributor, banned, muted, wikibanned, wikicontributor) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | ▶ | if ($param{mode} eq 'mute') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | $data->{type} = 'muted'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } elsif ($param{mode} eq 'contributor') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | $data->{type} = 'contributor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } elsif ($param{mode} eq 'moderator_invite') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | #print "modinvite\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | $data->{type} = 'moderator_invite'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | $data->{type} = 'banned'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | api => API_BAN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | ▶ | sub mute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | $param{mode} = 'mute'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | return $self->ban(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | ▶ | sub add_approved_user { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_approved_user: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 0 | $param{mode} = 'contributor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | return $self->ban(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | # more sensible version of add_approved_user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | sub approve_user { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
approve_user: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | my ($self, $user, $sub, $unapprove) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | my %param; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | $param{username} = $user || die "approve_user: arg 1 (username) is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$user || die("approve_user: arg 1 (username) is required.\n")
MC/DC0%0/1
$user || die("approve_user: arg 1 (username) is required.\n")
$user
Truth table0%0/2
A
A= $user
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | ▶ | $param{subreddit} = $sub || die "approve_user: arg 2 (sub) is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$sub || die("approve_user: arg 2 (sub) is required.\n")
MC/DC0%0/1
$sub || die("approve_user: arg 2 (sub) is required.\n")
$sub
Truth table0%0/2
A
A= $sub
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | $param{mode} = 'contributor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | ▶ | unless ($unapprove) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | return $self->ban(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | return $self->unban(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | ▶ | sub unapprove_user { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unapprove_user: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | my ($self, $user, $sub) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | ▶ | if (!$user){ die "unapprove_user: arg 1 (username) is required.\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | ▶ | if (!$sub) { die "unapprove_user: arg 2 (sub) is required.\n" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | return $self->approve_user($user, $sub, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | # Requires scope 'modothers' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | sub invite_moderator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invite_moderator: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | $param{mode} = 'moderator_invite'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | return $self->ban(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | # so we already had a function to do this and we wrote another one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | sub invite_mod { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invite_mod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | my ($this, $sub, $user) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | return $this->ban( # excellent naming of that function, bravo | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | user => $user, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | sub => $sub, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | mode => 'moderator_invite', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | sub unban { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unban: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit} || die "subreddit is required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || die("subreddit is required\n")
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || die("subreddit is required\n")
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | ▶ | $data->{name} = $param{username} || die "username is required\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'username'} || die("username is required\n")
MC/DC0%0/1
$param{'username'} || die("username is required\n")
$param{'username'}
Truth table0%0/2
A
A= $param{'username'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | # ban_context = fullname, but of what - not required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | ▶ | if ($param{mode} eq 'mute') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | $data->{type} = 'muted'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | } elsif ($param{mode} eq 'contributor') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | $data->{type} = 'contributor'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | $data->{type} = 'banned'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | api => API_UNBAN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | sub unmute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unmute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | $param{mode} = 'mute'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | return $self->unban(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | ▶ | sub distinguish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
distinguish: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 0 | my ($self, $fullname, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | ▶ | if (!iscomment($fullname) and !ispost($fullname)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
iscomment($fullname) or ispost($fullname)
MC/DC0%0/2
iscomment($fullname) or ispost($fullname)
iscomment($fullname)
ispost($fullname)
Truth table0%0/3
A or B
A= iscomment($fullname)B= ispost($fullname)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | die 'Fullname is required (comment preceeded by "t1_", post "t3_")'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | ▶ | if (iscomment($fullname)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | # only top level can be sticky | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | my $sticky = exists $param{sticky} ? $param{sticky} : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | ▶ | $data->{sticky} = $sticky ? 'true' : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | $data->{id} = $fullname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | $data->{how} = 'yes'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | # Check manual setting of 'how'. Normal users should never set 'how'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | ▶ | if ($param{how}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | my @valid = qw/yes no admin special/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | my $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | for (@valid) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | ▶ | if ($param{how} eq $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | $ok = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | last; # because we have to save potentially TWO CYCLES, right asshole? yeah spend all day on 2 cycles, that's a good use of your time | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | ▶ | die "valid values for 'how' are: yes, no, admin, special\n" unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | api => API_DISTINGUISH, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | ▶ | sub undistinguish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
undistinguish: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | my ($self, $fullname, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | ▶ | if (!iscomment($fullname) and !ispost($fullname)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
iscomment($fullname) or ispost($fullname)
MC/DC0%0/2
iscomment($fullname) or ispost($fullname)
iscomment($fullname)
ispost($fullname)
Truth table0%0/3
A or B
A= iscomment($fullname)B= ispost($fullname)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | die 'Fullname is required (comment preceeded by "t1_", post "t3_")'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | $data->{id} = $fullname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | $data->{how} = 'no'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | api => API_UNDISTINGUISH, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | # https://old.reddit.com/dev/api/#POST_api_report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | # Send a report. Don't know what most of these fields do. made them all optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | ▶ | sub report { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
report: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | my ($this, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | # Nearly all optional until we know what they do lol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | # is sub required, tho? Not for a sitewide report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | # required here so we don't accidentally send a sitewide report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | ▶ | $data->{custom_text} = $param{custom_text} if $param{custom_text}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | ▶ | $data->{from_help_desk} = bool($param{from_help_desk}) if exists $param{from_help_desk}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | ▶ | $data->{from_modmail} = bool($param{from_modmail}) if exists $param{from_modmail}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | ▶ | $data->{modmail_conv_id}= $param{modmail_conv_id} if $param{modmail_conv_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | ▶ | $data->{other_reason} = $param{other_reason} if $param{other_reason}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | ▶ | $data->{reason} = $param{reason} if $param{reason}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | ▶ | $data->{rule_reason} = $param{rule_reason} if $param{rule_reason}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | ▶ | $data->{site_reason} = $param{site_reason} if $param{site_reason}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | #$data->{sr_name} = $param{sub} || $param{subreddit} || croak "sub or subreddit is required."; # API says sr_name can be 1000 characters? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | ▶ | $data->{sr_name} = $param{sub}||$param{subreddit} if $param{sub}||$param{subreddit}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$param{"sub"} or $param{"subreddit"}
$param{'sub'} || $param{'subreddit'}
MC/DC0%0/2
$param{"sub"} or $param{"subreddit"}
$param{"sub"}
$param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'}
$param{'sub'}
$param{'subreddit'}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
Truth table0%0/3
A || B
A= $param{'sub'}B= $param{'subreddit'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | ▶ | my $id = $param{id}||$param{fullname} || croak "fullname (alias id) is required"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'id'} || $param{'fullname'} || croak('fullname (alias id) is required')
$param{"id"} or $param{"fullname"}
MC/DC0%0/2
$param{'id'} || $param{'fullname'} || croak('fullname (alias id) is required')
$param{"id"}
$param{"fullname"}
Truth table0%0/3
A or B
A= $param{"id"}B= $param{"fullname"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | ▶ | croak "fullname (alias id) must be a fullname" unless $id =~ /^t[0-9]_/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | $data->{thing_id} = $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | #$data->{strict_freeform_reports} = bool($param{strict_freeform_reports}) if exists $param{strict_freeform_reports}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | $data->{strict_freeform_reports} = "true"; # see docs | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | $data->{usernames} = $param{usernames} if $param{usernames}; # a comma-delimited list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | return $this->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | api => API_REPORT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | ▶ | sub get_modlinks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_modlinks: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | my $query = $self->set_listing_defaults(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit} || 'mod'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || 'mod'
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || 'mod'
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | ▶ | my $mode = $param{mode} || 'modqueue'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'mode'} || 'modqueue'
MC/DC0%0/1
$param{'mode'} || 'modqueue'
$param{'mode'}
Truth table0%0/2
A
A= $param{'mode'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | api => API_MODQ, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | args => [$sub, $mode], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | data => $query, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | #return $result->{data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | $_->{kind} eq "t1" ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | Reddit::Client::Comment->new($self, $_->{data}) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | Reddit::Client::Link->new($self, $_->{data}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | ▶ | sub get_modqueue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_modqueue: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | $param{mode} = 'modqueue'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | return $self->get_modlinks(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | # Get new modmail. This returns metadata and the first message for each conver- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | # sation. Full conversations must be loaded separately with get_conversation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | # after: conversation id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | # entity: comma-delimited list of subreddit names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # limit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | # sort: one of (recent, mod, user, unread) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | # state: one of (new, inprogress, mod, notifications, archived, highlighted, all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | # Returns: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | # conversationIds, array of conversation IDs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | # conversations, hash of data about the conversation, keys are conversation IDs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | # -subject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | # -numMessages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | # -state - corresponds to state arg? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | # -authors, array of hashes of information about each author | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | # -participant, hash of info about the user from the top message? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | # -owner, hash of info about the sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | ▶ | sub get_modmail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_modmail: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | ▶ | $data->{sort} = $param{sort} || 'unread'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'sort'} || 'unread'
MC/DC0%0/1
$param{'sort'} || 'unread'
$param{'sort'}
Truth table0%0/2
A
A= $param{'sort'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | ▶ | $data->{state} = $param{state} || 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'state'} || 'all'
MC/DC0%0/1
$param{'state'} || 'all'
$param{'state'}
Truth table0%0/2
A
A= $param{'state'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | ▶ | $data->{after} = $param{after} if $param{after}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | ▶ | $data->{limit} = exists $param{limit} ? ( $param{limit} ? $param{limit} : 500 ) : DEFAULT_LIMIT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | ▶ | my $subs = $param{entity} || $param{subreddits} || $param{subs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$param{'entity'} || $param{'subreddits'} || $param{'subs'}
$param{"entity"} or $param{"subreddits"}
MC/DC0%0/3
$param{'entity'} || $param{'subreddits'} || $param{'subs'}
$param{"entity"}
$param{"subreddits"}
$param{'subs'}
Truth table0%0/4
A or B || C
A= $param{"entity"}B= $param{"subreddits"}C= $param{'subs'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | ▶ | if ($subs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | ▶ | $subs = join ",", @$subs if ref $subs eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | $data->{entity} = $subs if $subs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | api => API_GET_MODMAIL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | # GET /api/mod/conversations/:conversation_id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | # Returns all messages, mod actions and conversation metadata for id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | # conversation_id base36 modmail conversation id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | # markRead boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | ▶ | sub get_conversation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_conversation: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 0 | my ($this, $id, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | # "This endpoint will create a ModmailConversation object as well as the first ModmailMessage within the ModmailConversation object." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | ▶ | sub new_modmail_conversation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_modmail_conversation: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | my ($this, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | ▶ | $data->{body} = $param{body} || croak "new_modmail_conversation: body is required."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'body'} || croak('new_modmail_conversation: body is required.')
MC/DC0%0/1
$param{'body'} || croak('new_modmail_conversation: body is required.')
$param{'body'}
Truth table0%0/2
A
A= $param{'body'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | # Unlike Reddit's functionality, this hides the author name by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | my $auth = exists $param{isAuthorHidden} ? $param{isAuthorHidden} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | ▶ | ( exists $param{hide_author} ? $param{hide_author} : 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | #$data->{isAuthorHidden} = exists $param{isAuthorHidden} ? ( $param{isAuthorHidden} ? "true" : "false" ) : "true"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | ▶ | $data->{isAuthorHidden} = $auth ? "true" : "false"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | $data->{srName} = $param{subreddit} || $param{sub} || $param{srName} || croak "new_modmail_conversation: subreddit is required (also accepts aliases 'sub' and 'srName')"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$param{'subreddit'} || $param{'sub'} || $param{'srName'} || croak(q[new_modmail_conversation: subreddit is required (also accepts aliases 'sub' and 'srName')])
$param{"subreddit"} or $param{"sub"} or $param{"srName"}
$param{"subreddit"} or $param{"sub"}
MC/DC0%0/3
$param{'subreddit'} || $param{'sub'} || $param{'srName'} || croak(q[new_modmail_conversation: subreddit is required (also accepts aliases 'sub' and 'srName')])
$param{"subreddit"}
$param{"sub"}
$param{"srName"}
Truth table0%0/4
A or B or C
A= $param{"subreddit"}B= $param{"sub"}C= $param{"srName"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | ▶ | my $subj = $param{subject} || croak "new_modmail_conversation: subject is required"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'subject'} || croak('new_modmail_conversation: subject is required')
MC/DC0%0/1
$param{'subject'} || croak('new_modmail_conversation: subject is required')
$param{'subject'}
Truth table0%0/2
A
A= $param{'subject'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | ▶ | if (length $subj > 100) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | print "new_modmail_conversation: subject truncated to 100 characters.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | $subj = substr $subj, 0, 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | $data->{subject} = $subj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | # users only or can subreddit be target? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | ▶ | $data->{to} = $param{to} || croak "new_modmail_conversation: fullname is required."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'to'} || croak('new_modmail_conversation: fullname is required.')
MC/DC0%0/1
$param{'to'} || croak('new_modmail_conversation: fullname is required.')
$param{'to'}
Truth table0%0/2
A
A= $param{'to'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | #$fullname = fullname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | # body, isAuthorHidden, srName, subject=100 chars, to=fullname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | # documentation is WRONG. to is not a fullname, it's just a username | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 0 | my $result = $this->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | api => API_NEW_MM_CONV, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 0 | ▶ | if (ref $result eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | return new Reddit::Client::ModmailConversation($this, $result->{conversation}, $result->{messages}, $result->{modActions}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | ▶ | sub sticky_post { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sticky_post: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | my ($this, $id, %opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | # docs say id but maybe they mean fullname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | ▶ | $id = fullname($id, 't3') || die "sticky_post: arg 1 (id) is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
fullname($id, 't3') || die("sticky_post: arg 1 (id) is required.\n")
MC/DC0%0/1
fullname($id, 't3') || die("sticky_post: arg 1 (id) is required.\n")
fullname($id, 't3')
Truth table0%0/2
A
A= fullname($id, 't3')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 0 | $data->{id} = $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | ▶ | if ($opt{num}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | ▶ | if ($opt{num} =~ /^[1234]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | $data->{num} = $opt{num}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | print "sticky_post: option 'num' must be an integer from 1-4. Unsetting.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | ▶ | $data->{state} = exists $opt{sticky} ? ($opt{sticky} ? "true" : "false") : "true"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 0 | ▶ | $data->{to_profile} = exists $opt{to_profile} ? ($opt{to_profile} ? "true" : "false") : "false"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 0 | return $this->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | api => API_STICKY_POST, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | #============================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | # New modmail functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | # most use the same URL format so we should make a central function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | # Sub for many modmail actions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | # these actions take no args, just the action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | # TODO: call these from ModmailConversation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | ▶ | sub modmail_action { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modmail_action: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 0 | my ($this, $action, $id) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | ▶ | croak "args 1 and 2 (action and id) are required" unless $action and $id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$action and $id
MC/DC0%0/2
$action and $id
$action
$id
Truth table0%0/3
A and B
A= $actionB= $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | $action = lc $action; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | # Choose MM_POST_ACTION or MM_GET_ACTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | # POST: bulk_read, approve (?), archive, disapprove (?), highlight, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | # unarchive, unban, unmute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | # POST: read and unread take single arg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | # POST: mute takes hours, has own function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | # POST: temp_ban takes duration, support elsehwere | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | # only hightlight uses DELETE, not supporting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | my @post_actions = qw/bulk_read approve archive disapprove highlight unarchive unban unmute /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | my $api; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | for (@post_actions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | ▶ | if ($action eq $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | $api = API_MM_POST_ACTION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 0 | ▶ | croak "'$action' is not a recognized action. only POST actions are implemented at this time." unless $api; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 0 | return $this->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | api => $api, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | args => [$id, $action], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | # num_hours one of (72, 168, 672) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 0 | ▶ | sub modmail_mute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
modmail_mute: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | my ($this, $id, $length) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | ▶ | $length ||= 72; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$length ||= 72
MC/DC0%0/1
$length ||= 72
$length
Truth table0%0/2
A
A= $length
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | # We should accept days too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | ▶ | if ($length == 3 or $length == 7 or $length == 28) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$length == 3 or $length == 7 or $length == 28
$length == 3 or $length == 7
MC/DC0%0/3
$length == 3 or $length == 7 or $length == 28
$length == 3
$length == 7
$length == 28
Truth table0%0/4
A or B or C
A= $length == 3B= $length == 7C= $length == 28
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | $length *= 24; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | ▶ | } elsif ($length != 72 and $length != 168 and $length != 672) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$length != 72 and $length != 168 and $length != 672
$length != 72 and $length != 168
MC/DC0%0/3
$length != 72 and $length != 168 and $length != 672
$length != 72
$length != 168
$length != 672
Truth table0%0/4
A and B and C
A= $length != 72B= $length != 168C= $length != 672
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | die "arg 2 (length) must be 3, 7, or 28 days (or 72, 168, or 672 hours)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | my $data = { num_hours => $length }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | my $args = [ $id ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | return $this->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | api => API_MM_MUTE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | #============================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | # Users | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | #============================================================= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | ▶ | sub get_user { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_user: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | #my ($self, %param) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | #$user = $param{user} || $param{username} || croak "expected 'user'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | #$view = $param{view} || 'overview'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | my ($user, $view, %param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | # old ver: user=>$user, view=>$view | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | # what if someone passes in another key? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | # this fails with unpredictable results lol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | # even elements = old way, odd = new way | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | my $odd = scalar(@_) % 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | ▶ | if (!$odd or $_[0] eq 'user' or $_[0] eq 'username' or $_[0] eq 'view') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not $odd or $_[0] eq "user" or $_[0] eq "username" or $_[0] eq "view"
not $odd or $_[0] eq "user" or $_[0] eq "username"
not $odd or $_[0] eq "user"
MC/DC0%0/4
not $odd or $_[0] eq "user" or $_[0] eq "username" or $_[0] eq "view"
not $odd
$_[0] eq "user"
$_[0] eq "username"
$_[0] eq "view"
Truth table0%0/5
not(A) or B or C or D
A= not $oddB= $_[0] eq "user"C= $_[0] eq "username"D= $_[0] eq "view"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | print "This form of get_user is deprecated. A future version will take the following simplified argument structure: get_user(\$username, \%params)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 0 | %param = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | ▶ | $user = $param{user} || $param{username} || croak "expected 'user'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'user'} || $param{'username'} || croak(q[expected 'user'])
$param{"user"} or $param{"username"}
MC/DC0%0/2
$param{'user'} || $param{'username'} || croak(q[expected 'user'])
$param{"user"}
$param{"username"}
Truth table0%0/3
A or B
A= $param{"user"}B= $param{"username"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | # new ver: $user, %params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | $user = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | 0 | %param= @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 0 | ▶ | $view = $param{view} || 'overview'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'view'} || 'overview'
MC/DC0%0/1
$param{'view'} || 'overview'
$param{'view'}
Truth table0%0/2
A
A= $param{'view'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | # This can accept limit as data? are all GET string args sent as data? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | my $data = $self->set_listing_defaults(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 0 | my $args = [$user, $view]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | # $API[API_USER ] = ['GET', '/user/%s/%s' ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | # view is different here; would need third arg, 'sort=new' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | # /user/TheUser/submitted?sort=new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | api => API_USER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | args => $args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | ▶ | if ($view eq 'about') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | return Reddit::Client::Account->new($self, $result->{data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | $_->{kind} eq "t1" ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | Reddit::Client::Comment->new($self, $_->{data}) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | Reddit::Client::Link->new($self, $_->{data}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | @{$result->{data}{children}} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | # Change posts or comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | ▶ | sub edit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
edit: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 0 | my ($self, $name, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | my $type = substr $name, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | ▶ | croak 'Argument 1 ($fullname) must be a post or comment.' if $type ne 't1' && $type ne 't3'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type ne "t1" and $type ne "t3"
MC/DC0%0/2
$type ne "t1" and $type ne "t3"
$type ne "t1"
$type ne "t3"
Truth table0%0/3
A and B
A= $type ne "t1"B= $type ne "t3"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 0 | ▶ | croak 'Argument 2 (text) is required. Empty strings are allowed.' unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | 0 | my $data = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | thing_id => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | text => $text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | api => API_EDIT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 0 | return $result->{data}{things}[0]{data}{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 0 | ▶ | croak 'Expected $fullname' if !$name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | my $type = substr $name, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 0 | ▶ | croak '$fullname must be a post or comment' if $type ne 't1' && $type ne 't3'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type ne "t1" and $type ne "t3"
MC/DC0%0/2
$type ne "t1" and $type ne "t3"
$type ne "t1"
$type ne "t3"
Truth table0%0/3
A and B
A= $type ne "t1"B= $type ne "t3"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 0 | DEBUG('Delete post/comment %s', $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 0 | my $result = $self->api_json_request(api => API_DEL, data => { id => $name }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | # Submitting links | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 0 | ▶ | sub submit_link { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_link: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | # why is sub allowed to be empty? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | ▶ | my $subreddit = $param{subreddit} || $param{sub} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'subreddit'} || $param{'sub'} || ''
$param{"subreddit"} or $param{"sub"}
MC/DC0%0/2
$param{'subreddit'} || $param{'sub'} || ''
$param{"subreddit"}
$param{"sub"}
Truth table0%0/3
A or B
A= $param{"subreddit"}B= $param{"sub"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 0 | ▶ | my $title = $param{title} || croak 'Expected "title"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'title'} || croak('Expected "title"')
MC/DC0%0/1
$param{'title'} || croak('Expected "title"')
$param{'title'}
Truth table0%0/2
A
A= $param{'title'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 0 | ▶ | my $url = $param{url} || croak 'Expected "url"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'url'} || croak('Expected "url"')
MC/DC0%0/1
$param{'url'} || croak('Expected "url"')
$param{'url'}
Truth table0%0/2
A
A= $param{'url'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | ▶ | my $replies = exists $param{inbox_replies} ? ($param{inbox_replies} ? "true" : "false") : "true"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | ▶ | my $repost = exists $param{repost} ? ($param{repost} ? "true" : "false") : "false"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | ▶ | my $nsfw = exists $param{nsfw} ? ($param{nsfw} ? "true" : "false") : "false"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | DEBUG('Submit link to %s: %s', $subreddit, $title, $url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | $subreddit = subreddit($subreddit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 0 | my $result = $self->api_json_request(api => API_SUBMIT, data => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | title => $title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | sr => $subreddit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | kind => SUBMIT_LINK, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | sendreplies => $replies, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | resubmit => $repost, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | nsfw => $nsfw, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | 0 | return $result->{data}{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 0 | ▶ | sub submit_crosspost { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_crosspost: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | # why is subreddit allowed to be empty? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | ▶ | my $subreddit = $param{subreddit} || $param{sub} || die "expected 'subreddit'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'subreddit'} || $param{'sub'} || die("expected 'subreddit'\n")
$param{"subreddit"} or $param{"sub"}
MC/DC0%0/2
$param{'subreddit'} || $param{'sub'} || die("expected 'subreddit'\n")
$param{"subreddit"}
$param{"sub"}
Truth table0%0/3
A or B
A= $param{"subreddit"}B= $param{"sub"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | ▶ | my $title = $param{title} || die "Expected 'title'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'title'} || die("Expected 'title'\n")
MC/DC0%0/1
$param{'title'} || die("Expected 'title'\n")
$param{'title'}
Truth table0%0/2
A
A= $param{'title'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | ▶ | my $source_id = $param{source_id} || die "Expected 'source_id'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'source_id'} || die("Expected 'source_id'\n")
MC/DC0%0/1
$param{'source_id'} || die("Expected 'source_id'\n")
$param{'source_id'}
Truth table0%0/2
A
A= $param{'source_id'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | ▶ | $source_id = "t3_$source_id" if lc substr($source_id, 0, 3) ne 't3_'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | #my $url = $param{url} || croak 'Expected "url"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 0 | ▶ | my $replies = exists $param{inbox_replies} ? ($param{inbox_replies} ? "true" : "false") : "true"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 0 | ▶ | my $repost = exists $param{repost} ? ($param{repost} ? "true" : "false") : "false"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 0 | $subreddit = subreddit($subreddit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 0 | my $result = $self->api_json_request(api => API_SUBMIT, data => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | title => $title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | #url => $url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | crosspost_fullname => $source_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | sr => $subreddit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | kind => SUBMIT_CROSSPOST, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | sendreplies => $replies, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | resubmit => $repost, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 0 | return $result->{data}{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 0 | ▶ | sub submit_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_text: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 0 | ▶ | my $subreddit = $param{subreddit} || $param{sub} || die "expected 'subreddit'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'subreddit'} || $param{'sub'} || die("expected 'subreddit'\n")
$param{"subreddit"} or $param{"sub"}
MC/DC0%0/2
$param{'subreddit'} || $param{'sub'} || die("expected 'subreddit'\n")
$param{"subreddit"}
$param{"sub"}
Truth table0%0/3
A or B
A= $param{"subreddit"}B= $param{"sub"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 0 | ▶ | my $title = $param{title} || croak 'Expected "title"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'title'} || croak('Expected "title"')
MC/DC0%0/1
$param{'title'} || croak('Expected "title"')
$param{'title'}
Truth table0%0/2
A
A= $param{'title'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | ▶ | my $text = $param{text} || "";#croak 'Expected "text"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'text'} || ''
MC/DC0%0/1
$param{'text'} || ''
$param{'text'}
Truth table0%0/2
A
A= $param{'text'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | # true and false have to be the strings "true" or "false" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 0 | ▶ | my $replies = exists $param{inbox_replies} ? ($param{inbox_replies} ? "true" : "false") : "true"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 0 | DEBUG('Submit text to %s: %s', $subreddit, $title); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | $subreddit = subreddit($subreddit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 0 | my $result = $self->api_json_request(api => API_SUBMIT, data => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | title => $title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | text => $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | sr => $subreddit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | kind => SUBMIT_SELF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | sendreplies=>$replies, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | return $result->{data}{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | # These could go in the user section or here, but it seems like it will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | # more commonly used for flairing posts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 0 | ▶ | sub template { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
template: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | my $data = {}; # POST data | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | my $url_arg; # arguments that get interpolated into the URL | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | api => API_FLAIR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | args => [$url_arg], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | data => $data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | # flair a post, not using an existing template, just manually providing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | # text and CSS class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | ▶ | sub flair_post { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flair_post: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 0 | ▶ | my $link_fullname = $param{link_id} || $param{post_id} || die "flair_post: need 'link_id'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'link_id'} || $param{'post_id'} || die("flair_post: need 'link_id'\n")
$param{"link_id"} or $param{"post_id"}
MC/DC0%0/2
$param{'link_id'} || $param{'post_id'} || die("flair_post: need 'link_id'\n")
$param{"link_id"}
$param{"post_id"}
Truth table0%0/3
A or B
A= $param{"link_id"}B= $param{"post_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 0 | $link_fullname = fullname($link_fullname, 't3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 0 | ▶ | my $subreddit = $param{sub} || $param{subreddit} || die "flair_post: need 'subreddit'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || die("flair_post: need 'subreddit'\n")
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || die("flair_post: need 'subreddit'\n")
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | # Initializing $text to '' here was accidentally preventing a concatenation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | # warning from Request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 0 | ▶ | my $text = $param{text} ? substr($param{text}, 0, 64) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 0 | my $css_class = $param{css_class}; # optional | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | my $data = { link => $link_fullname }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 0 | ▶ | $data->{text} = $text if $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 0 | ▶ | $data->{css_class} = $css_class if $css_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | api => API_FLAIR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | args => [$subreddit], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | data => $data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 0 | ▶ | sub flair_link { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flair_link: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | return $self->flair_post(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | # flair a user, not using an existing template, just manually providing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | # text and CSS class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | ▶ | sub flair_user { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flair_user: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | ▶ | my $username = $param{username} || die "flair_user: need 'link_id'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'username'} || die("flair_user: need 'link_id'\n")
MC/DC0%0/1
$param{'username'} || die("flair_user: need 'link_id'\n")
$param{'username'}
Truth table0%0/2
A
A= $param{'username'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | ▶ | my $text = $param{text} ? substr($param{text}, 0, 64) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 0 | my $css_class = $param{css_class}; #optional | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 0 | ▶ | my $subreddit = $param{sub} || $param{subreddit} || die "flair_user: need 'subreddit'\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || die("flair_user: need 'subreddit'\n")
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || die("flair_user: need 'subreddit'\n")
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 0 | my $data = { name => $username }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 0 | ▶ | $data->{text} = $text if $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | ▶ | $data->{css_class} = $css_class if $css_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | api => API_FLAIR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | args => [$subreddit], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | data => $data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | ▶ | sub set_post_flair { # select_flair alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_post_flair: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | #sub select_flair { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | #return $self->set_post_flair(%param); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 0 | return $self->select_flair(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | # select_flair can apply flair which appears styled in multi views (such as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | # r/all, your homepage, and both kinds of multis). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | # Flair applied through other methods has no style in multi views. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | # view sub newred | sub oldred | multi view | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | # Apply manually new reddit x x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | # API x x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | # Automod applies x x! x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | # -New reddit and multis always ignore CSS class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | # -Old reddit will have the new style IF it is applied by Automod and IF it has | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | # no css_class. Otherwise it uses old styles like usual. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | # -If a css_class is added by any means, old reddit will lose new styles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | # -If you alter the flair in any way through either the old or new interface, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | # old reddit will lose the new style. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | # -If text is altered with flair_link, old reddit will lose new styles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | # - Multi view (same as r/all view) seems to show whatever new reddit does. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | # - text_color and background_color seem to have no effect on anything. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | # Flair will use values from the flair selection as defaults. Some can only be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | # set through the new interface or the API. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | # It looks like flair templates with a background_color attempt to hard code the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | # background color - that is, they use style="" tags. There is no way to do this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | # with old reddit, only API and new. The override_css option in /r/api/flairtemplate2 may be related. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | #sub set_post_flair { # select_flair alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | 0 | ▶ | sub select_flair { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
select_flair: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | my $errmsg = "select_flair: 'subreddit' and 'flair_template_id' (or alias 'flair_id') are required.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit} || die $errmsg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || die($errmsg)
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || die($errmsg)
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | ▶ | my $flairid = $param{flair_template_id} || $param{flair_id} || die $errmsg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'flair_template_id'} || $param{'flair_id'} || die($errmsg)
$param{"flair_template_id"} or $param{"flair_id"}
MC/DC0%0/2
$param{'flair_template_id'} || $param{'flair_id'} || die($errmsg)
$param{"flair_template_id"}
$param{"flair_id"}
Truth table0%0/3
A or B
A= $param{"flair_template_id"}B= $param{"flair_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | my $post_id = $param{link_id} || $param{post_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$param{'link_id'} || $param{'post_id'}
MC/DC0%0/2
$param{'link_id'} || $param{'post_id'}
$param{'link_id'}
$param{'post_id'}
Truth table0%0/3
A || B
A= $param{'link_id'}B= $param{'post_id'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | # This doesn't use LINK_FLAIR or USER_FLAIR, it watches for link id or usern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | ▶ | if (!$post_id and !$param{username}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$post_id || $param{'username'}
MC/DC0%0/2
$post_id || $param{'username'}
$post_id
$param{'username'}
Truth table0%0/3
A || B
A= $post_idB= $param{'username'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 0 | die "select_flair: either 'link_id' or 'username' is required.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | } elsif ($post_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | $post_id = fullname($post_id, 't3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | my $textcol = $param{text_color}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | # putting an actual color here will be a common mistake | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 0 | ▶ | if ($textcol) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | $textcol = lc $textcol; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | ▶ | if ($textcol ne 'light' and $textcol ne 'dark') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$textcol ne "light" and $textcol ne "dark"
MC/DC0%0/2
$textcol ne "light" and $textcol ne "dark"
$textcol ne "light"
$textcol ne "dark"
Truth table0%0/3
A and B
A= $textcol ne "light"B= $textcol ne "dark"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | 0 | die "select_flair: if provided, text_color must be 'light' or 'dark'.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | ▶ | $data->{background_color} = $param{background_color} if $param{background_color}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | ▶ | $data->{css_class} = $param{css_class} if $param{css_class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 0 | $data->{flair_template_id} = $flairid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | 0 | ▶ | $data->{link} = $post_id if $post_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | ▶ | $data->{name} = $param{username} if $param{username}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 0 | ▶ | $data->{return_rtjson} = $param{return_rtjson} if $param{return_rtjson}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | ▶ | $data->{text_color} = $textcol if $textcol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | # if given empty string Reddit ignores the parameter-- i.e. you can't do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | # tricks like invisibly flair something, like you could with v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | # Also passing undef here gives a concatenation error in Request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | ▶ | $data->{text} = $param{text} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'text'} || ''
MC/DC0%0/1
$param{'text'} || ''
$param{'text'}
Truth table0%0/2
A
A= $param{'text'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | api => API_SELECTFLAIR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | data => $data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | ▶ | sub select_user_flair { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
select_user_flair: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | 0 | return $self->set_user_flair(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | ▶ | sub set_user_flair { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_user_flair: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | my $errmsg = "select_user_flair: keys 'subreddit', 'username', and 'flair_template_id' (or alias 'flair_id') are required.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | 0 | ▶ | my $sub = $param{subreddit} || die $errmsg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'subreddit'} || die($errmsg)
MC/DC0%0/1
$param{'subreddit'} || die($errmsg)
$param{'subreddit'}
Truth table0%0/2
A
A= $param{'subreddit'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | 0 | ▶ | my $user = $param{username} || die $errmsg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'username'} || die($errmsg)
MC/DC0%0/1
$param{'username'} || die($errmsg)
$param{'username'}
Truth table0%0/2
A
A= $param{'username'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 0 | ▶ | my $flairid = $param{flair_template_id} || $param{flair_id} || die $errmsg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'flair_template_id'} || $param{'flair_id'} || die($errmsg)
$param{"flair_template_id"} or $param{"flair_id"}
MC/DC0%0/2
$param{'flair_template_id'} || $param{'flair_id'} || die($errmsg)
$param{"flair_template_id"}
$param{"flair_id"}
Truth table0%0/3
A or B
A= $param{"flair_template_id"}B= $param{"flair_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | $data->{name} = $user; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | 0 | $data->{flair_template_id} = $flairid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | api => API_SELECTFLAIR, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | data => $data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | # Return a hash reference with keys 'choices' and 'current' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | # 'choices' is array of hashes with flair options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | # 'current' is the post's current flair | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 0 | ▶ | sub get_flair_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_flair_options: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit} || die "get_flair_options: 'subreddit' (or alias 'sub') is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || die("get_flair_options: 'subreddit' (or alias 'sub') is required.\n")
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || die("get_flair_options: 'subreddit' (or alias 'sub') is required.\n")
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | 0 | ▶ | my $post_id = $param{link_id} || $param{post_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$param{'link_id'} || $param{'post_id'}
MC/DC0%0/2
$param{'link_id'} || $param{'post_id'}
$param{'link_id'}
$param{'post_id'}
Truth table0%0/3
A || B
A= $param{'link_id'}B= $param{'post_id'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | ▶ | my $user = $param{user} || $param{name} || $param{username}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$param{'user'} || $param{'name'} || $param{'username'}
$param{"user"} or $param{"name"}
MC/DC0%0/3
$param{'user'} || $param{'name'} || $param{'username'}
$param{"user"}
$param{"name"}
$param{'username'}
Truth table0%0/4
A or B || C
A= $param{"user"}B= $param{"name"}C= $param{'username'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 0 | ▶ | if ($post_id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | 0 | $post_id = fullname($post_id, 't3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | 0 | $data->{link} = $post_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | } elsif ($user) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 0 | $data->{name} = $user; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | die "get_flair_options: Need 'post_id' or 'username'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | api => API_FLAIROPTS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | # What's this? Fixing the booleans? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | 0 | ▶ | if ($result->{choices}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | 0 | ▶ | for (my $i=0; $result->{choices}[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 0 | ▶ | $result->{choices}[$i]->{flair_text_editable} = $result->{choices}[$i]->{flair_text_editable} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 0 | ▶ | sub get_link_flair_options { # v2: default now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_link_flair_options: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | ▶ | my $sub = shift || die "get_link_flair_options: Need arg 1 (subreddit)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die("get_link_flair_options: Need arg 1 (subreddit)\n")
MC/DC0%0/1
shift() || die("get_link_flair_options: Need arg 1 (subreddit)\n")
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | api => API_LINKFLAIRV2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | ▶ | sub get_link_flair_options_v1 { # v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_link_flair_options_v1: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 0 | ▶ | my $sub = shift || die "get_link_flair_options: Need arg 1 (subreddit)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die("get_link_flair_options: Need arg 1 (subreddit)\n")
MC/DC0%0/1
shift() || die("get_link_flair_options: Need arg 1 (subreddit)\n")
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | api => API_LINKFLAIRV1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 0 | ▶ | sub get_user_flair_options { # v2: default now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_user_flair_options: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 0 | ▶ | my $sub = shift || die "get_link_flair_options: Need arg 1 (subreddit)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die("get_link_flair_options: Need arg 1 (subreddit)\n")
MC/DC0%0/1
shift() || die("get_link_flair_options: Need arg 1 (subreddit)\n")
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | api => API_USERFLAIRV2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 0 | ▶ | sub get_user_flair_options_v1 { # v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_user_flair_options_v1: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 0 | ▶ | my $sub = shift || die "get_link_flair_options: Need arg 1 (subreddit)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die("get_link_flair_options: Need arg 1 (subreddit)\n")
MC/DC0%0/1
shift() || die("get_link_flair_options: Need arg 1 (subreddit)\n")
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | api => API_USERFLAIRV1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | # uses flairtemplate_v2 endpoint, which is for new but works for old | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 0 | ▶ | sub flairtemplate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flairtemplate: not called CC=27 SCAR=66.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit} || die "flairtemplate: 'subreddit' (or alias 'sub') is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || die("flairtemplate: 'subreddit' (or alias 'sub') is required.\n")
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || die("flairtemplate: 'subreddit' (or alias 'sub') is required.\n")
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | 0 | ▶ | my $bg = $param{background_color} if $param{background_color}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | ▶ | my $flairid = $param{flair_template_id} || $param{flair_id} || $param{id} || undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$param{'flair_template_id'} || $param{'flair_id'} || $param{'id'} || undef
$param{"flair_template_id"} or $param{"flair_id"} or $param{"id"}
$param{"flair_template_id"} or $param{"flair_id"}
MC/DC0%0/3
$param{'flair_template_id'} || $param{'flair_id'} || $param{'id'} || undef
$param{"flair_template_id"}
$param{"flair_id"}
$param{"id"}
Truth table0%0/4
A or B or C
A= $param{"flair_template_id"}B= $param{"flair_id"}C= $param{"id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | #my $type = $param{flair_type} || die $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | ▶ | my $modonly = exists $param{mod_only} ? ($param{mod_only} ? 'true' : 'false') : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | ▶ | my $editable= exists $param{text_editable} ? ($param{text_editable} ? 'true' : 'false') : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 0 | my $textcol = $param{text_color}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | # putting an actual color here will be a common mistake | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 0 | ▶ | if ($textcol) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 0 | $textcol = lc $textcol; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | 0 | ▶ | if ($textcol ne 'light' and $textcol ne 'dark') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$textcol ne "light" and $textcol ne "dark"
MC/DC0%0/2
$textcol ne "light" and $textcol ne "dark"
$textcol ne "light"
$textcol ne "dark"
Truth table0%0/3
A and B
A= $textcol ne "light"B= $textcol ne "dark"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | 0 | die "flairtemplate: if provided, text_color must be one of (light, dark).\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | # override_css is undocumented and not returned by get_link_flair_options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | # $override is unused here as yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | #my $override= exists $param{override_css} ? ($param{override_css} ? 'true' : 'false') : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | 0 | ▶ | if ($bg and substr($bg, 0, 1) ne '#') { $bg = "#$bg"; } #requires hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$bg and substr($bg, 0, 1) ne "#"
MC/DC0%0/2
$bg and substr($bg, 0, 1) ne "#"
$bg
substr($bg, 0, 1) ne "#"
Truth table0%0/3
A and B
A= $bgB= substr($bg, 0, 1) ne "#"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | ▶ | $data->{allowable_content} = $param{allowable_content} if $param{allowable_content}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | ▶ | $data->{background_color} = $bg if $bg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | ▶ | $data->{css_class} = $param{css_class} if $param{css_class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | 0 | ▶ | $data->{max_emojis} = $param{max_emojis} if $param{max_emojis}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | # No documentation; presumably required for editing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | ▶ | $data->{flair_template_id} = $flairid if $flairid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | # api defaults to USER_FLAIR, we default to LINK_FLAIR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | 0 | ▶ | $data->{flair_type} = $param{flair_type} || 'LINK_FLAIR'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'flair_type'} || 'LINK_FLAIR'
MC/DC0%0/1
$param{'flair_type'} || 'LINK_FLAIR'
$param{'flair_type'}
Truth table0%0/2
A
A= $param{'flair_type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 0 | ▶ | $data->{mod_only} = $modonly if exists $param{mod_only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | # No documentation. Probably wants "true or "false". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | 0 | ▶ | $data->{override_css} = $param{override_css} if $param{override_css}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | ▶ | $data->{text} = $param{text} if $param{text}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | ▶ | $data->{text_color} = $textcol if $textcol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | ▶ | $data->{text_editable} = $editable if exists $param{text_editable}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | api => API_FLAIRTEMPLATE2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | #============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | # Subreddit management | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | #============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 0 | ▶ | sub get_wiki { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_wiki: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | 0 | ▶ | my $page = $param{page} || croak "Need 'page'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'page'} || croak(q[Need 'page'])
MC/DC0%0/1
$param{'page'} || croak(q[Need 'page'])
$param{'page'}
Truth table0%0/2
A
A= $param{'page'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit} || die "need subreddit\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || die("need subreddit\n")
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || die("need subreddit\n")
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | 0 | ▶ | $data->{v} = $param{v} if $param{v}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 0 | ▶ | $data->{v2} = $param{v2} if $param{v2}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | api => API_GETWIKI, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | args => [$sub, $page], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | 0 | ▶ | return $param{data} ? $result->{data} : $result->{data}->{content_md}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | 0 | ▶ | sub get_wiki_data { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_wiki_data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | 0 | $param{data} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | 0 | return $self->get_wiki(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | 0 | ▶ | sub edit_wiki { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
edit_wiki: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | ▶ | my $page = $param{page} || croak "Need 'page'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'page'} || croak(q[Need 'page'])
MC/DC0%0/1
$param{'page'} || croak(q[Need 'page'])
$param{'page'}
Truth table0%0/2
A
A= $param{'page'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | 0 | ▶ | my $content = defined $param{content} ? $param{content} : croak "Need 'content'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | # Reddit maximum length is 524,288 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 0 | ▶ | if (length $content > 524288) { croak "Maximum length for 'content' is 524288 bytes."; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit} || croak "Need 'sub' or 'subreddit'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'sub'} || $param{'subreddit'} || croak(q[Need 'sub' or 'subreddit'])
$param{"sub"} or $param{"subreddit"}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'} || croak(q[Need 'sub' or 'subreddit'])
$param{"sub"}
$param{"subreddit"}
Truth table0%0/3
A or B
A= $param{"sub"}B= $param{"subreddit"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | 0 | my $previous = $param{previous}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | 0 | my $reason = $param{reason}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | 0 | $data->{page} = $page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | 0 | $data->{content}= $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | 0 | ▶ | if ($previous) { $data->{previous} = $previous; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | 0 | ▶ | if ($reason) { $data->{reason} = substr $reason, 0, 256; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | api => API_EDITWIKI, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | args => [$sub], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | # Comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | 0 | ▶ | sub get_comments { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_comments: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 0 | my $permalink; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | 0 | ▶ | my $sub = $param{sub} || $param{subreddit}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$param{'sub'} || $param{'subreddit'}
MC/DC0%0/2
$param{'sub'} || $param{'subreddit'}
$param{'sub'}
$param{'subreddit'}
Truth table0%0/3
A || B
A= $param{'sub'}B= $param{'subreddit'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | 0 | ▶ | if ($param{permalink}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | 0 | $permalink = $param{permalink}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | ▶ | } elsif ($sub and $param{comment_id} and $param{link_id}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$sub and $param{"comment_id"} and $param{"link_id"}
$sub and $param{"comment_id"}
MC/DC0%0/3
$sub and $param{"comment_id"} and $param{"link_id"}
$sub
$param{"comment_id"}
$param{"link_id"}
Truth table0%0/4
A and B and C
A= $subB= $param{"comment_id"}C= $param{"link_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | 0 | my $id = id($param{link_id}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | 0 | my $cmtid = id($param{comment_id}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | $permalink = "/r/$sub/comments/$id//$cmtid"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | ▶ | } elsif ($sub and $param{id}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$sub and $param{"id"}
MC/DC0%0/2
$sub and $param{"id"}
$sub
$param{"id"}
Truth table0%0/3
A and B
A= $subB= $param{"id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | 0 | my $id = id($param{id}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 0 | $permalink = "/r/$sub/comments/$id"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | } elsif ($param{url}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | $permalink = $param{url}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 0 | $permalink =~ s/^https?:\/\/([a-zA-Z]{1,3}\.)?reddit\.com//i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | 0 | die "get_comments: Either 'permalink' OR 'url' OR 'subreddit' and 'link_id' OR 'subreddit' and 'link_id' and 'comment_id' are required.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 0 | my $result = $self->json_request('GET', $permalink); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 0 | my $link_id = $result->[0]{data}{children}[0]{data}{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | # result->[0] is a listing with 1 element, the link, even if you requested a cmt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | 0 | my $comments = $result->[1]{data}{children}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 0 | my $return = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 0 | for my $cmt (@$comments) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 0 | ▶ | if ($cmt->{kind} eq 't1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 0 | push @$return, Reddit::Client::Comment->new($self, $cmt->{data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | } elsif ($cmt->{kind} eq 'more') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 0 | my $more = Reddit::Client::MoreComments->new($self, $cmt->{data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 0 | $more->{link_id} = $link_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | 0 | push @$return, $more; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | # limit_children: get these comments and their descendants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | 0 | ▶ | sub get_collapsed_comments { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_collapsed_comments: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | 0 | ▶ | my $link_id = fullname($param{link_id},'t3') || die "load_more_comments: 'link_id' is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
fullname($param{'link_id'}, 't3') || die("load_more_comments: 'link_id' is required.\n")
MC/DC0%0/1
fullname($param{'link_id'}, 't3') || die("load_more_comments: 'link_id' is required.\n")
fullname($param{'link_id'}, 't3')
Truth table0%0/2
A
A= fullname($param{'link_id'}, 't3')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 0 | ▶ | my $children = $param{children} || die "get_collapsed_comments: 'children' is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'children'} || die("get_collapsed_comments: 'children' is required.\n")
MC/DC0%0/1
$param{'children'} || die("get_collapsed_comments: 'children' is required.\n")
$param{'children'}
Truth table0%0/2
A
A= $param{'children'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | 0 | ▶ | my $limit = exists $param{limit_children} ? ($param{limit_children} ? 'true' : 'false') : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | 0 | my $ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | 0 | ▶ | if (ref $children eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 0 | $ids = join ",", @$children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | 0 | ▶ | die "'children' must be non-empty array reference" unless $ids; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | 0 | die "get_collapsed_comments: 'children' must be array reference\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | 0 | my $data = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | link_id => $link_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | children => $ids, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | limit_children => $limit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | api_type => 'json', # This is the only GET endpoint that requires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | }; # api_type=json to be set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | 0 | ▶ | $data->{sort} = $param{sort} if $param{sort}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | 0 | ▶ | $data->{id} = $param{id} if $param{id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | api => API_MORECHILDREN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | 0 | my $comments = $result->{data}->{things}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | 0 | my $return = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | 0 | for my $cmt (@$comments) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | 0 | ▶ | if ($cmt->{kind} eq 't1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 0 | push @$return, Reddit::Client::Comment->new($self, $cmt->{data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | } elsif ($cmt->{kind} eq 'more') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | 0 | my $more = Reddit::Client::MoreComments->new($self, $cmt->{data}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | 0 | $more->{link_id} = $link_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 0 | push @$return, $more; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | 0 | return $return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 0 | ▶ | sub submit_comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit_comment: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | 0 | ▶ | my $parent_id = $param{parent} || $param{parent_id} || croak 'Expected "parent"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'parent'} || $param{'parent_id'} || croak('Expected "parent"')
$param{"parent"} or $param{"parent_id"}
MC/DC0%0/2
$param{'parent'} || $param{'parent_id'} || croak('Expected "parent"')
$param{"parent"}
$param{"parent_id"}
Truth table0%0/3
A or B
A= $param{"parent"}B= $param{"parent_id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | 0 | ▶ | my $comment = $param{text} || croak 'Expected "text"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'text'} || croak('Expected "text"')
MC/DC0%0/1
$param{'text'} || croak('Expected "text"')
$param{'text'}
Truth table0%0/2
A
A= $param{'text'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | # the replies option, it does nothing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | #my $replies = exists $param{inbox_replies} ? ($param{inbox_replies} ? "true" : "false") : "true"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 0 | ▶ | croak '$fullname must be a post or comment' if !ispost($parent_id) && !iscomment($parent_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ispost($parent_id) or iscomment($parent_id)
MC/DC0%0/2
ispost($parent_id) or iscomment($parent_id)
ispost($parent_id)
iscomment($parent_id)
Truth table0%0/3
A or B
A= ispost($parent_id)B= iscomment($parent_id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | 0 | DEBUG('Submit comment under %s', $parent_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | 0 | my $result = $self->api_json_request(api => API_COMMENT, data => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | thing_id => $parent_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | text => $comment, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | #sendreplies=>$replies, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | 0 | return $result->{data}{things}[0]{data}{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | 0 | ▶ | sub comment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | my($self, $parent, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | 0 | return $self->submit_comment(parent_id=>$parent, text=>$text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | # Private messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | 0 | ▶ | sub send_message { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_message: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | 0 | ▶ | my $to = $param{to} || croak 'Expected "to"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'to'} || croak('Expected "to"')
MC/DC0%0/1
$param{'to'} || croak('Expected "to"')
$param{'to'}
Truth table0%0/2
A
A= $param{'to'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | 0 | ▶ | my $subject = $param{subject} || croak 'Expected "subject"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'subject'} || croak('Expected "subject"')
MC/DC0%0/1
$param{'subject'} || croak('Expected "subject"')
$param{'subject'}
Truth table0%0/2
A
A= $param{'subject'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | 0 | ▶ | my $text = $param{text} || croak 'Expected "text"'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'text'} || croak('Expected "text"')
MC/DC0%0/1
$param{'text'} || croak('Expected "text"')
$param{'text'}
Truth table0%0/2
A
A= $param{'text'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | 0 | ▶ | croak '"subject" cannot be longer than 100 characters' if length $subject > 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | #$self->require_login; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | 0 | DEBUG('Submit message to %s: %s', $to, $subject); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | 0 | my $result = $self->api_json_request(api => API_MESSAGE, data => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | to => $to, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | subject => $subject, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | text => $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | kind => SUBMIT_MESSAGE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | # Voting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | 0 | ▶ | sub vote { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vote: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | 0 | my ($self, $name, $direction) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | 0 | ▶ | defined $name || croak 'Expected $name'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | ▶ | defined $direction || croak 'Expected $direction'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | 0 | ▶ | croak '$fullname must be a post or comment' if !ispost($name) && !iscomment($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ispost($name) or iscomment($name)
MC/DC0%0/2
ispost($name) or iscomment($name)
ispost($name)
iscomment($name)
Truth table0%0/3
A or B
A= ispost($name)B= iscomment($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | ▶ | croak 'Invalid vote direction' unless "$direction" =~ /^(-1|0|1)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | 0 | DEBUG('Vote %d for %s', $direction, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | $self->api_json_request(api => API_VOTE, data => { dir => $direction, id => $name }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | # Saving and hiding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | #=============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | 0 | ▶ | sub save { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | 0 | ▶ | my $name = shift || croak 'Expected $fullname'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || croak('Expected $fullname')
MC/DC0%0/1
shift() || croak('Expected $fullname')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | 0 | ▶ | croak '$fullname must be a post or comment' if !ispost($name) && !iscomment($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ispost($name) or iscomment($name)
MC/DC0%0/2
ispost($name) or iscomment($name)
ispost($name)
iscomment($name)
Truth table0%0/3
A or B
A= ispost($name)B= iscomment($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | 0 | DEBUG('Save %s', $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | 0 | $self->api_json_request(api => API_SAVE, data => { id => $name }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | 0 | ▶ | sub unsave { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unsave: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | 0 | ▶ | my $name = shift || croak 'Expected $fullname'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || croak('Expected $fullname')
MC/DC0%0/1
shift() || croak('Expected $fullname')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | ▶ | croak '$fullname must be a post or comment' if !ispost($name) && !iscomment($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ispost($name) or iscomment($name)
MC/DC0%0/2
ispost($name) or iscomment($name)
ispost($name)
iscomment($name)
Truth table0%0/3
A or B
A= ispost($name)B= iscomment($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | DEBUG('Unsave %s', $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | 0 | $self->api_json_request(api => API_UNSAVE, data => { id => $name }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | 0 | ▶ | sub hide { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hide: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | 0 | ▶ | my $name = shift || croak 'Expected $fullname'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || croak('Expected $fullname')
MC/DC0%0/1
shift() || croak('Expected $fullname')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | 0 | ▶ | croak '$fullname must be a post' if !ispost($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | 0 | DEBUG('Hide %s', $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | 0 | $self->api_json_request(api => API_HIDE, data => { id => $name }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | 0 | ▶ | sub unhide { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unhide: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | 0 | ▶ | my $name = shift || croak 'Expected $fullname'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || croak('Expected $fullname')
MC/DC0%0/1
shift() || croak('Expected $fullname')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | 0 | ▶ | croak '$fullname must be a post' if !ispost($name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | 0 | DEBUG('Unhide %s', $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | 0 | $self->api_json_request(api => API_UNHIDE, data => { id => $name }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | #============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | # Multireddits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | #============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | 0 | ▶ | sub edit_multi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
edit_multi: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | 0 | $param{edit} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | 0 | $self->create_multi(%param); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | 0 | ▶ | sub create_multi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_multi: not called CC=24 SCAR=64.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | 0 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | 0 | my $model = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | 0 | ▶ | my $username = $param{username} || $self->{username} || die "'username' is required."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$param{'username'} || $self->{'username'} || die(q['username' is required.])
$param{"username"} or $self->{"username"}
MC/DC0%0/2
$param{'username'} || $self->{'username'} || die(q['username' is required.])
$param{"username"}
$self->{"username"}
Truth table0%0/3
A or B
A= $param{"username"}B= $self->{"username"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | 0 | ▶ | $model->{display_name} = $param{name} || croak "Expected 'name'."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'name'} || croak(q[Expected 'name'.])
MC/DC0%0/1
$param{'name'} || croak(q[Expected 'name'.])
$param{'name'}
Truth table0%0/2
A
A= $param{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | 0 | ▶ | if (length($model->{display_name}) > 50) { croak "max length of 'name' is 50."; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | 0 | ▶ | $model->{description_md} = $param{description} if $param{description}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | ▶ | if ($param{icon_name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | 0 | $model->{icon_name} = $param{icon_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | 0 | my @iconnames = ('art and design', 'ask', 'books', 'business', 'cars', 'comics', 'cute animals', 'diy', 'entertainment', 'food and drink', 'funny', 'games', 'grooming', 'health', 'life advice', 'military', 'models pinup', 'music', 'news', 'philosophy', 'pictures and gifs', 'science', 'shopping', 'sports', 'style', 'tech', 'travel', 'unusual stories', 'video', '', 'None'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | 0 | my $match = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | 0 | foreach my $i (@iconnames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | 0 | ▶ | $match = 1 if $i eq $model->{icon_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | 0 | my $iconstr = join ", ", @iconnames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | 0 | ▶ | if (!$match) {croak "if 'icon_name' is provided, it must be one of the following values: $iconstr. Note that the purpose of icon_str is unclear and you should not use it unless you know what you're doing."; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | 0 | ▶ | if ($param{key_color}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | 0 | $model->{key_color} = "#".$param{key_color}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | 0 | ▶ | if (length($model->{key_color}) != 7) { croak "'key_color' must be a 6-character color code"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | 0 | ▶ | if ($param{visibility}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | 0 | $model->{visibility} = $param{visibility}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | 0 | ▶ | if ($model->{visibility} ne 'private' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$model->{"visibility"} ne "private" and $model->{"visibility"} ne "public" and $model->{"visibility"} ne "hidden"
$model->{"visibility"} ne "private" and $model->{"visibility"} ne "public"
MC/DC0%0/3
$model->{"visibility"} ne "private" and $model->{"visibility"} ne "public" and $model->{"visibility"} ne "hidden"
$model->{"visibility"} ne "private"
$model->{"visibility"} ne "public"
$model->{"visibility"} ne "hidden"
Truth table0%0/4
A and B and C
A= $model->{"visibility"} ne "private"B= $model->{"visibility"} ne "public"C= $model->{"visibility"} ne "hidden"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | $model->{visibility} ne 'public' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | $model->{visibility} ne 'hidden') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | 0 | croak "if provided, 'visibility' must be either 'public', 'private', or 'hidden'."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | 0 | ▶ | if ($param{weighting_scheme}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | 0 | $model->{weighting_scheme} = $param{weighting_scheme}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | 0 | ▶ | if ($model->{weighting_scheme} ne 'classic' and $model->{weighting_scheme} ne 'fresh') { croak "if 'weighting_scheme' is provided, it must be either 'classic' or 'fresh'"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$model->{"weighting_scheme"} ne "classic" and $model->{"weighting_scheme"} ne "fresh"
MC/DC0%0/2
$model->{"weighting_scheme"} ne "classic" and $model->{"weighting_scheme"} ne "fresh"
$model->{"weighting_scheme"} ne "classic"
$model->{"weighting_scheme"} ne "fresh"
Truth table0%0/3
A and B
A= $model->{"weighting_scheme"} ne "classic"B= $model->{"weighting_scheme"} ne "fresh"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | 0 | ▶ | if ($param{subreddits} or $param{subs}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$param{"subreddits"} or $param{"subs"}
MC/DC0%0/2
$param{"subreddits"} or $param{"subs"}
$param{"subreddits"}
$param{"subs"}
Truth table0%0/3
A or B
A= $param{"subreddits"}B= $param{"subs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | 0 | ▶ | $param{subreddits} = $param{subs} || $param{subreddits}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$param{'subs'} || $param{'subreddits'}
MC/DC0%0/2
$param{'subs'} || $param{'subreddits'}
$param{'subs'}
$param{'subreddits'}
Truth table0%0/3
A || B
A= $param{'subs'}B= $param{'subreddits'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | 0 | ▶ | if (ref $param{subreddits} ne 'ARRAY') { croak "'subreddits' must be an array reference."; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | 0 | $model->{subreddits} = [ map { { name=> $_ } } @{$param{subreddits}} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | #print Dumper($model->{subreddits}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | # Put a ribbon on it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | 0 | $data->{model} = JSON::encode_json($model); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | 0 | $data->{multipath} = "/user/$username/m/$model->{display_name}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | my $result = $self->api_json_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | api => $param{edit} ? API_EDITMULTI : API_CREATEMULTI, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | 0 | ▶ | args => [$username, $model->{display_name}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | 0 | return $result->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | ▶ | sub get_multi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_multi: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | 0 | ▶ | my $name = $param{name} || croak "expected 'name'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$param{'name'} || croak(q[expected 'name'])
MC/DC0%0/1
$param{'name'} || croak(q[expected 'name'])
$param{'name'}
Truth table0%0/2
A
A= $param{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | 0 | ▶ | my $username= $param{user} || $param{username} || $self->{username} || die "'username' is required.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$param{'user'} || $param{'username'} || $self->{'username'} || die("'username' is required.\n")
$param{"user"} or $param{"username"} or $self->{"username"}
$param{"user"} or $param{"username"}
MC/DC0%0/3
$param{'user'} || $param{'username'} || $self->{'username'} || die("'username' is required.\n")
$param{"user"}
$param{"username"}
$self->{"username"}
Truth table0%0/4
A or B or C
A= $param{"user"}B= $param{"username"}C= $self->{"username"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | 0 | ▶ | my $expand = $param{expand} ? '?expand_srs=true' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | 0 | my $result = $self->api_json_request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | api => API_GETMULTI, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | args => [$username, $name, $expand], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | # The result looks like a Subreddit object, but is not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | # By returning just the data we lose only the 'kind' key, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | # which is just the string "LabeledMulti" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | 0 | return $result->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | 0 | ▶ | sub delete_multi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_multi: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | 0 | ▶ | my $name = shift || croak "expected arg 1 (name)"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || croak('expected arg 1 (name)')
MC/DC0%0/1
shift() || croak('expected arg 1 (name)')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | my $result = $self->api_json_request( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | api => API_DELETEMULTI, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | 0 | args => [$self->{username}, $name], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | 0 | return $result->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | #============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | # Misc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | #============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | 0 | ▶ | sub get_origin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_origin: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | 0 | return "https://$self->{subdomain}.reddit.com"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | #============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | # Internal and static | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | #============================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | # Strip the type portion of a filname (i.e. t3_), if it exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | 0 | ▶ | sub id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | 0 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | 0 | $id =~ s/^t\d_//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | 0 | return $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | # accept id or fullname, always return fullname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | 0 | ▶ | sub fullname { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fullname: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | 0 | ▶ | my $id = shift || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | 0 | ▶ | my $type = shift || die "fullname: 'type' is required"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die(q[fullname: 'type' is required])
MC/DC0%0/1
shift() || die(q[fullname: 'type' is required])
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | 0 | ▶ | $id = $type."_".$id if substr($id, 0, 3) ne $type."_"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | 0 | return $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | 0 | ▶ | sub bool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bool: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | 0 | ▶ | return $_[0] ? "true" : "false"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | 0 | ▶ | sub ispost { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ispost: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | 0 | my $type = substr $name, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | 0 | return $type eq 't3'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | 0 | ▶ | sub iscomment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iscomment: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | 0 | my $type = substr($name, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | 0 | return $type eq 't1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | 0 | ▶ | sub get_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | 0 | ▶ | return lc substr($name, 0, 2) if $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | 2 | ▶ | sub DEBUG { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEBUG: called CC=2 SCAR=13.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | 2 | ▶ | if ($DEBUG) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | 0 | my ($format, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | 0 | my $ts = strftime "%Y-%m-%d %H:%M:%S", localtime; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | 0 | my $msg = sprintf $format, @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | 0 | chomp $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | 0 | printf STDERR "[%s] [ %s ]\n", $ts, $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | 0 | ▶ | sub subreddit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subreddit: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | 0 | my $subject = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | 0 | $subject =~ s/^\/r//; # trim leading /r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | 0 | $subject =~ s/^\///; # trim leading slashes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | 0 | $subject =~ s/\/$//; # trim trailing slashes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | 0 | ▶ | if ($subject !~ /\//) { # no slashes in name - it's probably good | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | 0 | ▶ | if ($subject eq '') { # front page | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | } else { # subreddit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | 0 | return $subject; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | } else { # fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | # Remember that this returns a new hash and any key not from here will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | # wiped out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | 0 | ▶ | sub set_listing_defaults { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_listing_defaults: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | 0 | my ($self, %param) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | 0 | my $query = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | 0 | ▶ | $query->{before} = $param{before} if $param{before}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | 0 | ▶ | $query->{after} = $param{after} if $param{after}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | 0 | ▶ | $query->{only} = $param{only} if $param{only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | 0 | ▶ | $query->{count} = $param{count} if $param{count}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | 0 | ▶ | $query->{show} = 'all' if $param{show} or $param{show_all}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$param{"show"} or $param{"show_all"}
MC/DC0%0/2
$param{"show"} or $param{"show_all"}
$param{"show"}
$param{"show_all"}
Truth table0%0/3
A or B
A= $param{"show"}B= $param{"show_all"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | 0 | ▶ | $query->{sort} = $param{sort} if $param{sort}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | 0 | ▶ | $query->{sr_detail} = 'true' if $param{sr_detail}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | # 500? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | 0 | ▶ | if (exists $param{limit}) { $query->{limit} = $param{limit} || 100; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$param{'limit'} || 100
MC/DC0%0/1
$param{'limit'} || 100
$param{'limit'}
Truth table0%0/2
A
A= $param{'limit'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | 0 | else { $query->{limit} = DEFAULT_LIMIT; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | 0 | return $query; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||