Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/chatlog/conduit/ChatLogQueryConduitAPIMethod.php
12241 views
1
<?php
2
3
final class ChatLogQueryConduitAPIMethod extends ChatLogConduitAPIMethod {
4
5
public function getAPIMethodName() {
6
return 'chatlog.query';
7
}
8
9
public function getMethodStatus() {
10
return self::METHOD_STATUS_UNSTABLE;
11
}
12
13
public function getMethodDescription() {
14
return pht('Retrieve chatter.');
15
}
16
17
protected function defineParamTypes() {
18
return array(
19
'channels' => 'optional list<string>',
20
'limit' => 'optional int (default = 100)',
21
);
22
}
23
24
protected function defineReturnType() {
25
return 'nonempty list<dict>';
26
}
27
28
protected function execute(ConduitAPIRequest $request) {
29
$query = new PhabricatorChatLogQuery();
30
31
$channel_ids = $request->getValue('channelIDs');
32
if ($channel_ids) {
33
$query->withChannelIDs($channel_ids);
34
}
35
36
$limit = $request->getValue('limit');
37
if (!$limit) {
38
$limit = 100;
39
}
40
$query->setLimit($limit);
41
42
$logs = $query->execute();
43
44
$results = array();
45
foreach ($logs as $log) {
46
$results[] = array(
47
'channelID' => $log->getChannelID(),
48
'epoch' => $log->getEpoch(),
49
'author' => $log->getAuthor(),
50
'type' => $log->getType(),
51
'message' => $log->getMessage(),
52
'loggedByPHID' => $log->getLoggedByPHID(),
53
);
54
}
55
56
return $results;
57
}
58
59
}
60
61