report.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. package model
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. // const const var
  7. const (
  8. // up主操作
  9. StatUpperInit = int8(0) // up主未处理
  10. StatUpperIgnore = int8(1) // up主已忽略
  11. StatUpperDelete = int8(2) // up主已删除
  12. // 管理员操作
  13. StatFirstInit = int8(0) // 待一审
  14. StatFirstDelete = int8(1) // 一审删除
  15. StatSecondInit = int8(2) // 待二审
  16. StatSecondDelete = int8(3) // 二审删除
  17. StatSecondIgnore = int8(4) // 二审忽略
  18. StatFirstIgnore = int8(5) // 一审忽略
  19. StatSecondAutoDelete = int8(6) // 二审脚本删除
  20. StatJudgeInit = int8(7) // 风纪委待审(二审)
  21. StatJudgeDelete = int8(8) // 风纪委删除(二审)
  22. StatJudgeIgnore = int8(9) // 风纪委忽略(二审)
  23. // 处理结果通知
  24. NoticeUnsend = int8(0) // 未通知用户
  25. NoticeSend = int8(1) // 已通知用户
  26. // 举报通知状态
  27. NoticeReporter = int8(1)
  28. NoticePoster = int8(2)
  29. NoticeAll = int8(3)
  30. // 举报原因
  31. ReportReasonProhibited = int8(1) // 违禁
  32. ReportReasonPorn = int8(2) // 色情
  33. RptReasonFraud = int8(3) // 赌博诈骗
  34. ReportReasonAttack = int8(4) // 人身攻击
  35. ReportReasonPrivate = int8(5) // 隐私
  36. ReportReasonAd = int8(6) // 广告
  37. ReportReasonWar = int8(7) // 引战
  38. ReportReasonSpoiler = int8(8) // 剧透
  39. ReportReasonMeaningless = int8(9) // 刷屏
  40. ReportReasonUnrelated = int8(10) // 视频不相关
  41. ReportReasonOther = int8(11) // 其他
  42. ReportReasonTeenagers = int8(12) // 青少年不良信息
  43. )
  44. // var const map
  45. var (
  46. RptTemplate = map[string]string{
  47. "del": `您好,您在视频#{%s}{"http://www.bilibili.com/av%d"}中举报的弹幕『%s』已被删除%s,原因是『%s』,感谢您对bilibili社区秩序的维护,哔哩哔哩 (゜-゜)つロ 干杯~`,
  48. "ignore": `您好,非常感谢您的举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中举报的弹幕『%s』暂未认定为违规内容,具体弹幕规范烦请参阅 #{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},哔哩哔哩 (゜-゜)つロ 干杯~`,
  49. }
  50. PostTemplate = map[int8]string{
  51. 1: `您好,根据用户举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中的弹幕『%s』已被删除%s,原因是『%s』,请自觉遵守国家相关法律法规,具体弹幕规范烦请参阅#{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},bilibili良好的社区氛围需要大家一起维护!`,
  52. 2: `您好,根据用户举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中的弹幕『%s』已被删除%s,原因是『%s』,bilibili倡导平等友善的交流,具体弹幕规范烦请参阅#{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},良好的社区氛围需要大家一起维护!`,
  53. 3: `您好,根据用户举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中的弹幕『%s』已被删除%s,原因是『%s』,弹幕是公众场所而非私人场所,具体弹幕规范烦请参阅#{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},良好的社区氛围需要大家一起维护!`,
  54. 4: `您好,根据用户举报,您在视频#{%s}{"http://www.bilibili.com/av%d"}中的弹幕『%s』已被删除%s,原因是『%s』,bilibili倡导发送与视频相关、有用的弹幕,具体弹幕规范烦请参阅#{《弹幕礼仪》}{"http://www.bilibili.com/blackboard/help.html#d5"},良好的社区氛围需要大家一起维护!`,
  55. }
  56. AdminRptReason = map[int8]string{
  57. 1: "内容涉及传播不实信息",
  58. 2: "内容涉及非法网站信息",
  59. 3: "内容涉及怂恿教唆信息",
  60. 4: "内容涉及低俗信息",
  61. 5: "内容涉及色情",
  62. 6: "内容涉及赌博诈骗信息",
  63. 7: "内容涉及人身攻击",
  64. 8: "内容涉及侵犯他人隐私",
  65. 9: "内容涉及垃圾广告",
  66. 10: "内容涉及引战",
  67. 11: "内容涉及视频剧透",
  68. 12: "恶意刷屏",
  69. 13: "视频不相关",
  70. 14: "其他",
  71. 15: "内容涉及违禁相关",
  72. 16: "内容不适宜",
  73. 17: "内容涉及青少年不良信息",
  74. }
  75. BlockReason = map[int8]string{
  76. 4: "发布赌博诈骗信息",
  77. 5: "发布违禁相关信息",
  78. 6: "发布垃圾广告信息",
  79. 7: "发布人身攻击言论",
  80. 8: "发布侵犯他人隐私信息",
  81. 9: "发布引战言论",
  82. 10: "发布剧透信息",
  83. 13: "发布色情信息",
  84. 14: "发布低俗信息",
  85. 17: "发布非法网站信息",
  86. 18: "发布传播不实信息",
  87. 19: "发布怂恿教唆信息",
  88. 20: "恶意刷屏",
  89. 24: "发布青少年不良内容",
  90. }
  91. )
  92. // ReportListParams .
  93. type ReportListParams struct {
  94. States []int64 `form:"state,split"`
  95. UpOps []int64 `form:"upop,split"`
  96. Tids []int64 `form:"tid,split"`
  97. Aid int64 `form:"aid"`
  98. Cid int64 `form:"cid"`
  99. UID int64 `form:"uid"`
  100. RpUID int64 `form:"rp_user"`
  101. RpTypes []int64 `form:"rp_type,split"`
  102. Start string `form:"start"`
  103. End string `form:"end"`
  104. Sort string `form:"sort"`
  105. Order string `form:"order"`
  106. Keyword string `form:"keyword"`
  107. Page int32 `form:"page" default:"1"`
  108. PageSize int32 `form:"page_size" default:"100" validate:"max=1000"`
  109. }
  110. // Report dm report struct.
  111. type Report struct {
  112. DidStr string `json:"dmid_str"` // str id
  113. ID int64 `json:"id"`
  114. Did int64 `json:"dmid"` // 弹幕id
  115. Cid int64 `json:"cid"` // 视频的id
  116. Aid int64 `json:"arc_aid"` // 稿件的id
  117. Tid int64 `json:"arc_typeid"` // 稿件的分区id
  118. UID int64 `json:"dm_owner_uid"` // 弹幕发送者的uid
  119. Msg string `json:"dm_msg"` // 弹幕内容
  120. Count int64 `json:"count"` // 被举报次数
  121. Content string `json:"content"` // 举报内容:只有类别其他才有值
  122. UpOP int8 `json:"up_op"` // up主操作状态
  123. State int8 `json:"state"` // 举报状态
  124. RpUID int64 `json:"uid"` // 最后一个举报用户id
  125. RpTime string `json:"rp_time"` // 举报时间
  126. RpType int64 `json:"reason"` // 举报类型
  127. Title string `json:"arc_title"` // 稿件标题
  128. Deleted int64 `json:"dm_deleted"` // 弹幕状态
  129. UPUid int64 `json:"arc_mid"` // up主id
  130. PoolID int64 `json:"pool_id"` // 弹幕池
  131. Model int64 `json:"model"` // 弹幕model
  132. Score int32 `json:"score"` // 举报分
  133. SendTime string `json:"dm_ctime"` // 弹幕发送时间
  134. Ctime string `json:"ctime"` // 插入时间
  135. Mtime string `json:"mtime"` // 更新时间
  136. RptUsers []*ReportUser `json:"user"` // 举报用户列表
  137. }
  138. // ReportMsg report message
  139. type ReportMsg struct {
  140. Aid int64
  141. Uids string
  142. Did int64
  143. Title string
  144. Msg string
  145. State int8
  146. RptReason int8
  147. BlockReason int8
  148. Block int64
  149. }
  150. // ReportJudge report judge
  151. type ReportJudge struct {
  152. AID int64 `json:"aid"`
  153. MID int64 `json:"mid"`
  154. Operator string `json:"operator"`
  155. OperID int64 `json:"oper_id"`
  156. OContent string `json:"origin_content"`
  157. OTitle string `json:"origin_title"`
  158. OType int64 `json:"origin_type"`
  159. OURL string `json:"origin_url"`
  160. ReasonType int64 `json:"reason_type"`
  161. OID int64 `json:"oid"`
  162. RPID int64 `json:"rp_id"`
  163. TagID int64 `json:"tag_id"`
  164. Type int64 `json:"type"`
  165. Page int64 `json:"page"`
  166. BTime int64 `json:"business_time"`
  167. }
  168. // SearchReportResult dm repost list from search
  169. type SearchReportResult struct {
  170. Code int64 `json:"code"`
  171. Order string `json:"order"`
  172. Sort string `json:"sort"`
  173. Page *struct {
  174. Num int64 `json:"num"`
  175. Size int64 `json:"size"`
  176. Total int64 `json:"total"`
  177. } `json:"page"`
  178. Result []*Report `json:"result"`
  179. }
  180. // UptSearchReport update search report
  181. type UptSearchReport struct {
  182. DMid int64 `json:"dmid"`
  183. State int8 `json:"state"`
  184. Ctime string `json:"ctime"`
  185. Mtime string `json:"mtime"`
  186. }
  187. // ReportList dm report list
  188. type ReportList struct {
  189. Code int64 `json:"code"`
  190. Order string `json:"order"`
  191. Page int64 `json:"page"`
  192. PageSize int64 `json:"pagesize"`
  193. PageCount int64 `json:"pagecount"`
  194. Total int64 `json:"total"`
  195. Result []*Report `json:"result"`
  196. }
  197. // ReduceMoral reduce moral
  198. type ReduceMoral struct {
  199. UID int64
  200. Moral int64
  201. Origin int8
  202. Reason int8
  203. ReasonType int8
  204. Operator string
  205. IsNotify int8
  206. Remark string
  207. }
  208. // BlockUser block user
  209. type BlockUser struct {
  210. UID int64
  211. BlockForever int64
  212. BlockTimeLength int64
  213. BlockRemark string
  214. Operator string
  215. OriginType int64
  216. Moral int64
  217. ReasonType int64
  218. OriginTitle string
  219. OriginContent string
  220. OriginURL string
  221. IsNotify int64
  222. }
  223. // ReportUser report user
  224. type ReportUser struct {
  225. ID int64 `json:"id"`
  226. Did int64 `json:"dmid"`
  227. UID int64 `json:"uid"`
  228. Reason int64 `json:"reason"`
  229. State int8 `json:"state"`
  230. Ctime time.Time `json:"ctime"`
  231. Mtime time.Time `json:"mtime"`
  232. }
  233. // ReportLog dm admin log
  234. type ReportLog struct {
  235. ID int64 `json:"id"`
  236. Did int64 `json:"dmid"`
  237. AdminID int64 `json:"admin_id"`
  238. Reason int8 `json:"reason"`
  239. Result int8 `json:"result"`
  240. Remark string `json:"remark"`
  241. Elapsed int64 `json:"elapsed"`
  242. Ctime time.Time `json:"ctime"`
  243. Mtime time.Time `json:"mtime"`
  244. }
  245. // PosterBlockMsg return report msg template by blockReason
  246. func PosterBlockMsg(reason int8) (str string, err error) {
  247. var (
  248. tmplKey int8
  249. )
  250. switch reason {
  251. case 4, 5, 13, 14, 17, 18, 19, 20, 24:
  252. tmplKey = 1
  253. case 6, 9:
  254. tmplKey = 2
  255. case 7, 8, 10, 12:
  256. tmplKey = 3
  257. default:
  258. err = fmt.Errorf("BlockReason %d not exist", reason)
  259. return
  260. }
  261. str = PostTemplate[tmplKey]
  262. return
  263. }
  264. // PosterAdminRptMsg return report msg template by adminRptReason
  265. func PosterAdminRptMsg(reason int8) (str string, err error) {
  266. var (
  267. tmplKey int8
  268. )
  269. switch reason {
  270. case 1, 2, 3, 4, 5, 6, 15, 17:
  271. tmplKey = 1
  272. case 7, 10:
  273. tmplKey = 2
  274. case 8, 9, 11, 12:
  275. tmplKey = 3
  276. case 13, 14, 16:
  277. tmplKey = 4
  278. default:
  279. err = fmt.Errorf("adminRptReason %d not exist", reason)
  280. return
  281. }
  282. str = PostTemplate[tmplKey]
  283. return
  284. }
  285. // RpReasonToJudgeReason 修改弹幕风纪委的理由
  286. func RpReasonToJudgeReason(r int8) (j int8) {
  287. switch r {
  288. case ReportReasonProhibited:
  289. j = 5
  290. case ReportReasonPorn:
  291. j = 13
  292. case RptReasonFraud:
  293. j = 4
  294. case ReportReasonAttack:
  295. j = 7
  296. case ReportReasonPrivate:
  297. j = 8
  298. case ReportReasonAd:
  299. j = 6
  300. case ReportReasonWar:
  301. j = 9
  302. case ReportReasonSpoiler:
  303. j = 10
  304. case ReportReasonMeaningless:
  305. j = 20
  306. }
  307. return
  308. }
  309. // CheckStateBelong check state first or second check
  310. func CheckStateBelong(state int8) string {
  311. if state == StatFirstInit || state == StatFirstDelete || state == StatFirstIgnore {
  312. return "弹幕举报一审"
  313. }
  314. return "弹幕举报二审"
  315. }