conference.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package action
  2. import (
  3. "errors"
  4. "pbx-api-gin/internal/app/ami"
  5. )
  6. func ListRoom(options map[string]string) (res map[string]string, err error) {
  7. action := map[string]string{
  8. "Action": "ConfbridgeListRooms",
  9. }
  10. for key, value := range options {
  11. action[key] = value
  12. }
  13. res, _, err = ami.AminInstance.Send(action)
  14. if err != nil {
  15. return nil, err
  16. }
  17. if res["Response"] != "Success" {
  18. return nil, errors.New(res["Message"])
  19. }
  20. return res, nil
  21. }
  22. func List(confnum string) (res map[string]string, err error) {
  23. action := map[string]string{
  24. "Action": "ConfbridgeList",
  25. "Conference": confnum,
  26. }
  27. res, _, err = ami.AminInstance.Send(action)
  28. if err != nil {
  29. return nil, err
  30. }
  31. if res["Response"] != "Success" {
  32. return nil, errors.New(res["Message"])
  33. }
  34. return res, nil
  35. }
  36. func Kick(confnum, channel string) (res map[string]string, err error) {
  37. action := map[string]string{
  38. "Action": "ConfbridgeKick",
  39. "Conference": confnum,
  40. "Channel": channel,
  41. }
  42. res, _, err = ami.AminInstance.Send(action)
  43. if err != nil {
  44. return nil, err
  45. }
  46. if res["Response"] != "Success" {
  47. return nil, errors.New(res["Message"])
  48. }
  49. return res, nil
  50. }
  51. func Mute(confnum, channel string) (res map[string]string, err error) {
  52. action := map[string]string{
  53. "Action": "ConfbridgeMute",
  54. "Conference": confnum,
  55. "Channel": channel,
  56. }
  57. res, _, err = ami.AminInstance.Send(action)
  58. if err != nil {
  59. return nil, err
  60. }
  61. if res["Response"] != "Success" {
  62. return nil, errors.New(res["Message"])
  63. }
  64. return res, nil
  65. }
  66. func UnMute(confnum, channel string) (res map[string]string, err error) {
  67. action := map[string]string{
  68. "Action": "ConfbridgeUnmute",
  69. "Conference": confnum,
  70. "Channel": channel,
  71. }
  72. res, _, err = ami.AminInstance.Send(action)
  73. if err != nil {
  74. return nil, err
  75. }
  76. if res["Response"] != "Success" {
  77. return nil, errors.New(res["Message"])
  78. }
  79. return res, nil
  80. }
  81. func Lock(confnum string) (res map[string]string, err error) {
  82. action := map[string]string{
  83. "Action": "ConfbridgeLock",
  84. "Conference": confnum,
  85. }
  86. res, _, err = ami.AminInstance.Send(action)
  87. if err != nil {
  88. return nil, err
  89. }
  90. if res["Response"] != "Success" {
  91. return nil, errors.New(res["Message"])
  92. }
  93. return res, nil
  94. }
  95. func UnLock(confnum string) (res map[string]string, err error) {
  96. action := map[string]string{
  97. "Action": "ConfbridgeUnlock",
  98. "Conference": confnum,
  99. }
  100. res, _, err = ami.AminInstance.Send(action)
  101. if err != nil {
  102. return nil, err
  103. }
  104. if res["Response"] != "Success" {
  105. return nil, errors.New(res["Message"])
  106. }
  107. return res, nil
  108. }