MessageAction no practical effect, just check if token is valid
(c *gin.Context)
| 20 | |
| 21 | // MessageAction no practical effect, just check if token is valid |
| 22 | func MessageAction(c *gin.Context) { |
| 23 | token := c.Query("token") |
| 24 | toUserId := c.Query("to_user_id") |
| 25 | content := c.Query("content") |
| 26 | |
| 27 | if user, exist := usersLoginInfo[token]; exist { |
| 28 | userIdB, _ := strconv.Atoi(toUserId) |
| 29 | chatKey := genChatKey(user.Id, int64(userIdB)) |
| 30 | |
| 31 | atomic.AddInt64(&messageIdSequence, 1) |
| 32 | curMessage := Message{ |
| 33 | Id: messageIdSequence, |
| 34 | Content: content, |
| 35 | CreateTime: time.Now().Format(time.Kitchen), |
| 36 | } |
| 37 | |
| 38 | if messages, exist := tempChat[chatKey]; exist { |
| 39 | tempChat[chatKey] = append(messages, curMessage) |
| 40 | } else { |
| 41 | tempChat[chatKey] = []Message{curMessage} |
| 42 | } |
| 43 | c.JSON(http.StatusOK, Response{StatusCode: 0}) |
| 44 | } else { |
| 45 | c.JSON(http.StatusOK, Response{StatusCode: 1, StatusMsg: "User doesn't exist"}) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // MessageChat all users have same follow list |
| 50 | func MessageChat(c *gin.Context) { |
nothing calls this directly
no test coverage detected