MCPcopy Index your code
hub / github.com/RaymondCode/simple-demo / MessageAction

Function MessageAction

controller/message.go:22–47  ·  view source on GitHub ↗

MessageAction no practical effect, just check if token is valid

(c *gin.Context)

Source from the content-addressed store, hash-verified

20
21// MessageAction no practical effect, just check if token is valid
22func 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
50func MessageChat(c *gin.Context) {

Callers

nothing calls this directly

Calls 1

genChatKeyFunction · 0.85

Tested by

no test coverage detected