Weixin/Model/Remote/_webwxinit.pm

filter: Statementstmt 24.0% 13 / 54 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 66.6% 4 / 6 Podpod n/a totaltotal 19.3% 17 / 88 CC 20 SCAR 56.9
CC
20
Cov
17%
_webwxinit
369.4
BEGIN
1.1
__ANON__
1.1
CRAP 295.7
« Weixin/Model/Remote/_webwxgetcontact.pm ↑ Summary Weixin/Plugin/Perldoc.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Mojo::Weixin::Const qw(%KEY_MAP_USER %KEY_MAP_GROUP %KEY_MAP_GROUP_MEMBER %KEY_MAP_FRIEND);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 0 ▶sub Mojo::Weixin::_webwxinit{
Subroutine _webwxinit: not called CC=20 SCAR=59.1
5 0 my $self = shift;
6 0 my $api = "https://". $self->domain . "/cgi-bin/mmwebwx-bin/webwxinit";
7 my @query_string = (
8 0 ▶ r => sub{use integer;unpack 'i',~ pack 'l',$self->now() & 0xFFFFFFFF}->(),
Subroutine BEGIN: called CC=1 SCAR=0.6
Subroutine __ANON__: not called CC=1 SCAR=0.6
9 );
10 0 ▶ push @query_string,(pass_ticket => $self->url_escape($self->pass_ticket)) if $self->pass_ticket;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pass_ticket 0 0 0
11 0 my $post = {
12 BaseRequest => {
13 Uin => $self->wxuin,
14 Sid => $self->wxsid,
15 Skey => $self->skey,
16 DeviceID => $self->deviceid,
17 },
18 };
19
20 0 my $json = $self->http_post($self->gen_url($api,@query_string),{json=>1,Referer=>'https://'.$self->domain .'/'},json=>$post);
21 0 ▶ return if not defined $json;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $json 0 0 0
22 0 ▶ return if $json->{BaseResponse}{Ret}!=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"BaseResponse"}{"Ret"} != 0 0 0 0
23 0 ▶ $self->sync_key($json->{SyncKey}) if $json->{SyncKey}{Count} !=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"SyncKey"}{"Count"} != 0 0 0 0
24 0 ▶ $self->skey($json->{Skey}) if $json->{Skey};
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"Skey"} 0 0 0
25 0 my $user = {};
26 0 for(keys %KEY_MAP_USER){
27 0 ▶ $user->{$_} = $json->{User}{$KEY_MAP_USER{$_}} // "";
Condition0%0/2
$json->{"User"}{$Mojo::Weixin::Model::KEY_MAP_USER{$_}} // ""
l!l
00
MC/DC0%0/1
$json->{"User"}{$Mojo::Weixin::Model::KEY_MAP_USER{$_}} // ""
$json->{"User"}{$Mojo::Weixin::Model::KEY_MAP_USER{$_}}
Truth table0%0/2
A
A= $json->{"User"}{$Mojo::Weixin::Model::KEY_MAP_USER{$_}}
Aresult
11
00
28 }
29  
30 0 my @friends;
31 my @groups;
32 0 for my $e (@{ $json->{ContactList} }){
33 0 ▶ if($self->is_group_id($e->{UserName})){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_group_id($e->{'UserName'})) { } 0 0 0
34 0 my $group = {};
35 0 for(keys %KEY_MAP_GROUP){
36 0 ▶ $group->{$_} = $e->{$KEY_MAP_GROUP{$_}} // "";
Condition0%0/2
$$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}} // ""
l!l
00
MC/DC0%0/1
$$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}} // ""
$$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}}
Truth table0%0/2
A
A= $$e{$Mojo::Weixin::Model::KEY_MAP_GROUP{$_}}
Aresult
11
00
37 }
38 0 for my $m (@{$e->{MemberList}}){
39 0 my $member = {_group_id=>$group->{id}};
40 0 for(keys %KEY_MAP_GROUP_MEMBER){
41 0 ▶ $member->{$_} = $m->{$KEY_MAP_GROUP_MEMBER{$_}} // "";
Condition0%0/2
$$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}} // ""
l!l
00
MC/DC0%0/1
$$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}} // ""
$$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}}
Truth table0%0/2
A
A= $$m{$Mojo::Weixin::Model::KEY_MAP_GROUP_MEMBER{$_}}
Aresult
11
00
42 }
43 0 $member->{sex} = $self->code2sex($member->{sex});
44 0 push @{$group->{member}},$member;
45 }
46 0 push @groups,$group;
47 }
48 else{
49 0 my $friend = {};
50 0 for(keys %KEY_MAP_FRIEND){
51 0 ▶ $friend->{$_} = $e->{$KEY_MAP_FRIEND{$_}} // "" ;
Condition0%0/2
$$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}} // ""
l!l
00
MC/DC0%0/1
$$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}} // ""
$$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}}
Truth table0%0/2
A
A= $$e{$Mojo::Weixin::Model::KEY_MAP_FRIEND{$_}}
Aresult
11
00
52 }
53 0 $friend->{sex} = $self->code2sex($friend->{sex});
54 0 push @friends,$friend;
55 }
56 }
57
58 0 ▶ my @id = $json->{ChatSet}?split /,/,$json->{ChatSet}:();
Branch: 1 branch
BranchTrueFalseTotal
$json->{'ChatSet'} ? : 0 0 0
59 0 for(@id){
60 0 ▶ if($self->is_group_id($_)){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_group_id($_)) { } 0 0 0
61 0 push @groups,{id=>$_};
62 }
63 else{
64 0 push @friends,{id=>$_};
65 }
66 }
67 0 return [$user,\@friends,\@groups];
68 }
69 1 1
« Weixin/Model/Remote/_webwxgetcontact.pm ↑ Summary Weixin/Plugin/Perldoc.pm »