3 final class ChatLogRecordConduitAPIMethod
extends ChatLogConduitAPIMethod
{
5 public function getAPIMethodName() {
6 return 'chatlog.record';
9 public function getMethodStatus() {
10 return self
::METHOD_STATUS_UNSTABLE
;
13 public function getMethodDescription() {
14 return pht('Record chatter.');
17 protected function defineParamTypes() {
19 'logs' => 'required list<dict>',
23 protected function defineReturnType() {
27 protected function execute(ConduitAPIRequest
$request) {
28 $logs = $request->getValue('logs');
29 if (!is_array($logs)) {
33 $template = new PhabricatorChatLogEvent();
34 $template->setLoggedByPHID($request->getUser()->getPHID());
37 foreach ($logs as $log) {
38 $channel_name = idx($log, 'channel');
39 $service_name = idx($log, 'serviceName');
40 $service_type = idx($log, 'serviceType');
42 $channel = id(new PhabricatorChatLogChannel())->loadOneWhere(
43 'channelName = %s AND serviceName = %s AND serviceType = %s',
49 $channel = id(new PhabricatorChatLogChannel())
50 ->setChannelName($channel_name)
51 ->setserviceName($service_name)
52 ->setServiceType($service_type)
53 ->setViewPolicy(PhabricatorPolicies
::POLICY_USER
)
54 ->setEditPolicy(PhabricatorPolicies
::POLICY_USER
)
58 $obj = clone $template;
59 $obj->setChannelID($channel->getID());
60 $obj->setType(idx($log, 'type'));
61 $obj->setAuthor(idx($log, 'author'));
62 $obj->setEpoch(idx($log, 'epoch'));
63 $obj->setMessage(idx($log, 'message'));
69 return array_values(mpull($objs, 'getID'));