diff --git a/app/controllers/users/messages_controller.rb b/app/controllers/users/messages_controller.rb index 0433d41ad..24c2a1934 100644 --- a/app/controllers/users/messages_controller.rb +++ b/app/controllers/users/messages_controller.rb @@ -25,7 +25,7 @@ class Users::MessagesController < Users::BaseController "sender": 4, "receiver": 2, "content": "Atme Message Content 2", - "status": 0, + "status": 2, "type": 2, "source": "IssueAtme", "notification_url": "http://www.baidu.com", @@ -47,7 +47,7 @@ class Users::MessagesController < Users::BaseController "sender": -1, "receiver": 2, "content": "Notification Message Content 2", - "status": 0, + "status": 2, "type": 1, "source": "IssueChanged", "notification_url": "http://www.baidu.com", @@ -58,7 +58,7 @@ class Users::MessagesController < Users::BaseController "sender": -1, "receiver": 2, "content": "Notification Message Content 3", - "status": 0, + "status": 2, "type": 1, "source": "ProjectJoined", "notification_url": "http://www.baidu.com", diff --git a/app/docs/slate/source/includes/_users.md b/app/docs/slate/source/includes/_users.md index f49fdcf6b..71a16ee87 100644 --- a/app/docs/slate/source/includes/_users.md +++ b/app/docs/slate/source/includes/_users.md @@ -1,7 +1,7 @@ # Users @@ -67,7 +67,7 @@ await octokit.request('GET /api/users/:login/messages.json') 参数 | 类型 | 字段说明 --------- | ----------- | ----------- |type | string | 消息类型,不传为所有消息,notification为系统消息,atme为@我消息| -|status | integer | 是否已读,不传为所有消息,0为未读,1为已读 | +|status | integer | 是否已读,不传为所有消息,1为未读,2为已读 | |limit | integer | 每页个数 | |page | integer | 页码 | @@ -79,7 +79,7 @@ await octokit.request('GET /api/users/:login/messages.json') |unread_notification | integer | 未读系统通知数量 | |unread_atme | integer | 未读@我数量 | |messages.id | integer | 消息id | -|messages.status | integer | 消息是否已读,0为未读,1为已读 | +|messages.status | integer | 消息是否已读,1为未读,2为已读 | |messages.content | string | 消息内容 | |messages.notification_url | string | 消息跳转地址 | |messages.source | string | 消息来源 | @@ -136,6 +136,7 @@ await octokit.request('GET /api/users/:login/messages.json') "content": "Atme Message Content 1", "notification_url": "http://www.baidu.com", "source": "PullRequestAtme", + "time_ago": "1天前", "type": "atme", "sender": { "id": 5, @@ -151,6 +152,7 @@ await octokit.request('GET /api/users/:login/messages.json') "content": "Atme Message Content 2", "notification_url": "http://www.baidu.com", "source": "IssueAtme", + "time_ago": "1天前", "type": "atme", "sender": { "id": 4, @@ -166,6 +168,7 @@ await octokit.request('GET /api/users/:login/messages.json') "content": "Notification Message Content 1", "notification_url": "http://www.baidu.com", "source": "IssueDelete", + "time_ago": "1天前", "type": "notification" }, { @@ -174,6 +177,7 @@ await octokit.request('GET /api/users/:login/messages.json') "content": "Notification Message Content 2", "notification_url": "http://www.baidu.com", "source": "IssueChanged", + "time_ago": "1天前", "type": "notification" }, { @@ -182,6 +186,7 @@ await octokit.request('GET /api/users/:login/messages.json') "content": "Notification Message Content 3", "notification_url": "http://www.baidu.com", "source": "ProjectJoined", + "time_ago": "1天前", "type": "notification" } ] diff --git a/app/views/users/messages/_message.json.jbuilder b/app/views/users/messages/_message.json.jbuilder index 1d8a9b264..9f6f0c504 100644 --- a/app/views/users/messages/_message.json.jbuilder +++ b/app/views/users/messages/_message.json.jbuilder @@ -6,6 +6,8 @@ json.status message["status"] json.content message["content"] json.notification_url message["notification_url"] json.source message["source"] +json.time_ago time_from_now(message["created_at"].to_time) + case message["type"] when 1 json.type "notification" diff --git a/public/docs/api.html b/public/docs/api.html index b6083dcd2..faabfbc7e 100644 --- a/public/docs/api.html +++ b/public/docs/api.html @@ -921,7 +921,7 @@ Success — a happy kitten is an authenticated kitten!

Users

获取当前登陆用户信息

@@ -1009,7 +1009,7 @@ Success — a happy kitten is an authenticated kitten! status integer -是否已读,不传为所有消息,0为未读,1为已读 +是否已读,不传为所有消息,1为未读,2为已读 limit @@ -1058,7 +1058,7 @@ Success — a happy kitten is an authenticated kitten! messages.status integer -消息是否已读,0为未读,1为已读 +消息是否已读,1为未读,2为已读 messages.content @@ -1230,6 +1230,7 @@ Success — a happy kitten is an authenticated kitten! "content": "Atme Message Content 1", "notification_url": "http://www.baidu.com", "source": "PullRequestAtme", + "time_ago": "1天前", "type": "atme", "sender": { "id": 5, @@ -1245,6 +1246,7 @@ Success — a happy kitten is an authenticated kitten! "content": "Atme Message Content 2", "notification_url": "http://www.baidu.com", "source": "IssueAtme", + "time_ago": "1天前", "type": "atme", "sender": { "id": 4, @@ -1260,6 +1262,7 @@ Success — a happy kitten is an authenticated kitten! "content": "Notification Message Content 1", "notification_url": "http://www.baidu.com", "source": "IssueDelete", + "time_ago": "1天前", "type": "notification" }, { @@ -1268,6 +1271,7 @@ Success — a happy kitten is an authenticated kitten! "content": "Notification Message Content 2", "notification_url": "http://www.baidu.com", "source": "IssueChanged", + "time_ago": "1天前", "type": "notification" }, { @@ -1276,6 +1280,7 @@ Success — a happy kitten is an authenticated kitten! "content": "Notification Message Content 3", "notification_url": "http://www.baidu.com", "source": "ProjectJoined", + "time_ago": "1天前", "type": "notification" } ]