event.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package model
  2. import "strings"
  3. type PresenceStateChange struct {
  4. Event string `json:"event"`
  5. Status string `json:"status"`
  6. Message string `json:"message"`
  7. Presentity string `json:"presentity"`
  8. Extension string `json:"extension"`
  9. DndStatus string `json:"dndStatus"`
  10. }
  11. type Hangup struct {
  12. AccountCode string `json:"accountCode"`
  13. CallerIDName string `json:"callerIDName"`
  14. CallerIDNum string `json:"callerIDNumber"`
  15. Cause string `json:"cause"`
  16. Causetxt string `json:"causetxt"`
  17. Channel string `json:"channel"`
  18. ChannelState string `json:"channelState"`
  19. ChannelStateDesc string `json:"channelStateDesc"`
  20. ConnectedLineName string `json:"connectedLineName"`
  21. ConnectedLineNum string `json:"connectedLineNumber"`
  22. Context string `json:"context"`
  23. Event string `json:"event"`
  24. Exten string `json:"exten"`
  25. Linkedid string `json:"linkedid"`
  26. Priority string `json:"priority"`
  27. Privilege string `json:"privilege"`
  28. Timestamp string `json:"timestamp"`
  29. Uniqueid string `json:"uniqueid"`
  30. }
  31. type Newstate struct {
  32. AccountCode string `json:"accountCode"`
  33. CallerIDName string `json:"callerIDName"`
  34. CallerIDNum string `json:"callerIDNumber"`
  35. Channel string `json:"channel"`
  36. ChannelState string `json:"channelState"`
  37. ChannelStateDesc string `json:"channelStateDesc"`
  38. ConnectedLineName string `json:"connectedLineName"`
  39. ConnectedLineNum string `json:"connectedLineNumber"`
  40. Context string `json:"context"`
  41. Event string `json:"event"`
  42. Exten string `json:"exten"`
  43. Language string `json:"language"`
  44. Linkedid string `json:"linkedid"`
  45. Priority string `json:"priority"`
  46. Privilege string `json:"privilege"`
  47. Timestamp string `json:"timestamp"`
  48. Uniqueid string `json:"uniqueid"`
  49. }
  50. type SuccessfulAuth struct {
  51. Event string `json:"event"`
  52. AccountID string `json:"accountID"`
  53. RemoteAddress string `json:"remoteAddress"`
  54. Address string `json:"address"`
  55. }
  56. func (event *SuccessfulAuth) GetAddress() {
  57. data := strings.Split(event.RemoteAddress, "/")
  58. if len(data) == 4 {
  59. event.Address = data[2]
  60. } else {
  61. event.Address = event.RemoteAddress
  62. }
  63. }
  64. type ContactStatus struct {
  65. Event string `json:"event"`
  66. URI string `json:"url"`
  67. ContactStatus string `json:"contactStatus"`
  68. Address string `json:"address"`
  69. AOR string `json:"extension"`
  70. RoundtripUsec string `json:"roundtripUsec"`
  71. }
  72. func (event *ContactStatus) GetAddress() {
  73. data := strings.Split(event.URI, "@")
  74. if len(data) == 2 {
  75. event.Address = strings.Split(data[1], ":")[0]
  76. }
  77. }
  78. type MessageWaiting struct {
  79. Event string `json:"event"`
  80. Extension string `json:"extension"`
  81. New string `json:"new"`
  82. Old string `json:"old"`
  83. Mailbox string `json:"mainbox"`
  84. }
  85. func (event *MessageWaiting) GetExtension() {
  86. data := strings.Split(event.Mailbox, "@")
  87. if len(data) == 2 {
  88. event.Extension = data[0]
  89. }
  90. }