line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
sub Mojo::Webqq::Model::_get_discuss_info { |
2
|
0
|
|
|
0
|
|
|
my $self = shift; |
3
|
0
|
|
|
|
|
|
my $did = shift; |
4
|
0
|
|
|
|
|
|
my $callback = shift; |
5
|
0
|
|
|
|
|
|
my $api_url = 'http://d1.web2.qq.com/channel/get_discu_info'; |
6
|
0
|
|
|
|
|
|
my @query_string = ( |
7
|
|
|
|
|
|
|
did => $did, |
8
|
|
|
|
|
|
|
vfwebqq => $self->vfwebqq, |
9
|
|
|
|
|
|
|
clientid => $self->clientid, |
10
|
|
|
|
|
|
|
psessionid => $self->psessionid, |
11
|
|
|
|
|
|
|
t => time(), |
12
|
|
|
|
|
|
|
); |
13
|
0
|
|
|
|
|
|
my $headers = { |
14
|
|
|
|
|
|
|
Referer => 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2', |
15
|
|
|
|
|
|
|
json => 1, |
16
|
|
|
|
|
|
|
ua_request_timeout => $self->model_update_timeout, |
17
|
|
|
|
|
|
|
ua_retry_times => 3, |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
my $is_blocking = ref $callback eq "CODE"?0:1; |
21
|
|
|
|
|
|
|
my $handle = sub{ |
22
|
0
|
|
|
0
|
|
|
my $json = shift; |
23
|
0
|
0
|
|
|
|
|
return unless defined $json; |
24
|
0
|
0
|
|
|
|
|
return undef if $json->{retcode}!=0; |
25
|
0
|
0
|
|
|
|
|
return undef unless exists $json->{result}{info}; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my %mem_list; |
28
|
|
|
|
|
|
|
my %mem_status; |
29
|
0
|
|
|
|
|
|
my %mem_info; |
30
|
0
|
|
|
|
|
|
my $minfo = []; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
for(@{ $json->{result}{info}{mem_list} }){ |
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$mem_list{$_->{mem_uin}}{ruin} = $_->{ruin}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
for(@{ $json->{result}{mem_status} }){ |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$mem_status{$_->{uin}}{status} = $_->{status}; |
38
|
0
|
|
|
|
|
|
$mem_status{$_->{uin}}{client_type} = $_->{client_type}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
for(@{ $json->{result}{mem_info} }){ |
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$mem_info{$_->{uin}}{nick} = $_->{nick}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $discuss_info = { |
46
|
|
|
|
|
|
|
id => $json->{result}{info}{did}, |
47
|
|
|
|
|
|
|
owner_id => $json->{result}{info}{discu_owner}, |
48
|
|
|
|
|
|
|
name => $json->{result}{info}{discu_name}, |
49
|
0
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
for(keys %mem_list){ |
52
|
|
|
|
|
|
|
my $m = { |
53
|
|
|
|
|
|
|
id => $_, |
54
|
|
|
|
|
|
|
name => $mem_info{$_}{nick}, |
55
|
|
|
|
|
|
|
uid => $mem_list{$_}{ruin}, |
56
|
|
|
|
|
|
|
_discuss_id => $discuss_info->{did}, |
57
|
0
|
|
|
|
|
|
}; |
58
|
0
|
0
|
|
|
|
|
if(exists $mem_status{$_}){ |
59
|
0
|
|
|
|
|
|
$m->{state} = $mem_status{$_}{status}; |
60
|
0
|
|
|
|
|
|
$m->{client_type} = $self->code2client($mem_status{$_}{client_type}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else{ |
63
|
0
|
|
|
|
|
|
$m->{state} = 'offline'; |
64
|
0
|
|
|
|
|
|
$m->{client_type} = 'unknown'; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
push @{$minfo},$m; |
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
$discuss_info->{ member } = $minfo if @$minfo>0; |
70
|
0
|
|
|
|
|
|
return $discuss_info; |
71
|
0
|
|
|
|
|
|
}; |
72
|
0
|
0
|
|
|
|
|
if($is_blocking){ |
73
|
0
|
|
|
|
|
|
return $handle->( $self->http_get($self->gen_url($api_url,@query_string),$headers,) ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else{ |
76
|
|
|
|
|
|
|
$self->http_get($self->gen_url($api_url,@query_string),$headers,sub{ |
77
|
0
|
|
|
0
|
|
|
my $json = shift; |
78
|
0
|
|
|
|
|
|
$callback->( $handle->($json) ); |
79
|
0
|
|
|
|
|
|
}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
1; |