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.

channelreg.go 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
  2. // released under the MIT license
  3. package irc
  4. import (
  5. "encoding/json"
  6. "time"
  7. "github.com/ergochat/ergo/irc/modes"
  8. "github.com/ergochat/ergo/irc/utils"
  9. )
  10. // this is exclusively the *persistence* layer for channel registration;
  11. // channel creation/tracking/destruction is in channelmanager.go
  12. // these are bit flags indicating what part of the channel status is "dirty"
  13. // and needs to be read from memory and written to the db
  14. const (
  15. IncludeInitial uint = 1 << iota
  16. IncludeTopic
  17. IncludeModes
  18. IncludeLists
  19. IncludeSettings
  20. )
  21. // this is an OR of all possible flags
  22. const (
  23. IncludeAllAttrs = ^uint(0)
  24. )
  25. // RegisteredChannel holds details about a given registered channel.
  26. type RegisteredChannel struct {
  27. // Name of the channel.
  28. Name string
  29. // UUID for the datastore.
  30. UUID utils.UUID
  31. // RegisteredAt represents the time that the channel was registered.
  32. RegisteredAt time.Time
  33. // Founder indicates the founder of the channel.
  34. Founder string
  35. // Topic represents the channel topic.
  36. Topic string
  37. // TopicSetBy represents the host that set the topic.
  38. TopicSetBy string
  39. // TopicSetTime represents the time the topic was set.
  40. TopicSetTime time.Time
  41. // Modes represents the channel modes
  42. Modes []modes.Mode
  43. // Key represents the channel key / password
  44. Key string
  45. // Forward is the forwarding/overflow (+f) channel
  46. Forward string
  47. // UserLimit is the user limit (0 for no limit)
  48. UserLimit int
  49. // AccountToUMode maps user accounts to their persistent channel modes (e.g., +q, +h)
  50. AccountToUMode map[string]modes.Mode
  51. // Bans represents the bans set on the channel.
  52. Bans map[string]MaskInfo
  53. // Excepts represents the exceptions set on the channel.
  54. Excepts map[string]MaskInfo
  55. // Invites represents the invite exceptions set on the channel.
  56. Invites map[string]MaskInfo
  57. // Settings are the chanserv-modifiable settings
  58. Settings ChannelSettings
  59. }
  60. func (r *RegisteredChannel) Serialize() ([]byte, error) {
  61. return json.Marshal(r)
  62. }
  63. func (r *RegisteredChannel) Deserialize(b []byte) (err error) {
  64. return json.Unmarshal(b, r)
  65. }
  66. type ChannelPurgeRecord struct {
  67. NameCasefolded string `json:"Name"`
  68. UUID utils.UUID
  69. Oper string
  70. PurgedAt time.Time
  71. Reason string
  72. }
  73. func (c *ChannelPurgeRecord) Serialize() ([]byte, error) {
  74. return json.Marshal(c)
  75. }
  76. func (c *ChannelPurgeRecord) Deserialize(b []byte) error {
  77. return json.Unmarshal(b, c)
  78. }