You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.7 KiB

  1. <?php
  2. use Moxl\Xec\Action\Message\Retract;
  3. include_once WIDGETS_PATH.'ContactActions/ContactActions.php';
  4. class ChatActions extends \Movim\Widget\Base
  5. {
  6. /**
  7. * @brief Get a Drawer view of a contact
  8. */
  9. public function ajaxGetContact($jid)
  10. {
  11. $c = new ContactActions;
  12. $c->ajaxGetDrawer($jid);
  13. }
  14. /**
  15. * @brief Display the message dialog
  16. */
  17. public function ajaxShowMessageDialog(string $mid)
  18. {
  19. $message = $this->user->messages()
  20. ->where('mid', $mid)
  21. ->first();
  22. if ($message) {
  23. $view = $this->tpl();
  24. $view->assign('message', $message);
  25. Dialog::fill($view->draw('_chatactions_message'));
  26. }
  27. }
  28. /**
  29. * @brief Edit a message
  30. */
  31. public function ajaxEditMessage($mid)
  32. {
  33. $this->rpc('Dialog.clear');
  34. $this->rpc('Chat.editMessage', $mid);
  35. }
  36. /**
  37. * @brief Retract a message
  38. *
  39. * @param string $to
  40. * @param string $mid
  41. * @return void
  42. */
  43. public function ajaxHttpDaemonRetract($mid)
  44. {
  45. $retract = $this->user->messages()
  46. ->where('mid', $mid)
  47. ->first();
  48. if ($retract && $retract->originid) {
  49. $this->rpc('Dialog.clear');
  50. $r = new Retract;
  51. $r->setTo($retract->jidto)
  52. ->setOriginid($retract->originid)
  53. ->request();
  54. $retract->retract();
  55. $retract->save();
  56. $packet = new \Moxl\Xec\Payload\Packet;
  57. $packet->content = $retract;
  58. $c = new Chat;
  59. $c->onMessage($packet, false, true);
  60. }
  61. }
  62. }