class Gitter::API::Message
Model representation of the /room/:room_id/chatMessages*
REST endpoints in the gitter API
Attributes
ISO formatted date of when the message originally sent
HTML formatted message (formatted on the API
server)
Message
id (from gitter)
List of github issues referened in the message
List of Gitter::API::User
mentioned in the message
Number of users that have read the message
Original message in plain-text/markdown
Indicates if the message has been read by the client user
ISO formatted data of when the message was edited last (if it has been)
List of URLs present in the message
Gitter::API::User
that sent the message
Public Class Methods
INTERNAL METHOD
Initialize a new Gitter::API::Message
Used by Gitter::API::Room
when fetching messages, so favor using that instead.
Parameters¶ ↑
Note: messages in the Gitter
schema don't have a `room_id`, so that is passed in as an additional arg here.
- client (
Gitter::API::Client
) -
Configured client object
- room_id (String)
-
Room
ID message came from - data (Hash)
-
Initialization data
Options¶ ↑
(string keys only)
- id (String)
-
Message
id - user (String)
-
Gitter::API::User
that sent the message - text (String)
-
Original message in plain-text/markdown
- html (String)
-
HTML formatted message
- unread (Boolean)
-
Indicates if current user has read the message
- read_by (Integer)
-
Number of users that have read the message
- created_at (Date)
-
ISO formatted date of the message
- updated_at (Date)
-
ISO formatted date of the message if edited
- mentions (Array<User>)
-
Gitter::API::User
(s) mentioned in message - issues (Array<String>)
-
List of #Issues referenced in the message
- urls (Array<String>)
-
List of URLs present in message
# File lib/gitter/api/message.rb, line 82 def initialize client, room_id, data super client, data @room_id = room_id @id = data["id"] @user = User.new client, data["fromUser"] @text = data["text"] @html = data["html"] @unread = data["unread"] @read_by = data["readBy"] @created_at = data["sent"] @updated_at = data["editedAt"] @mentions = data["mentions"].map { |user| User.new client, user } @issues = data["issues"] @urls = data["urls"] end
Public Instance Methods
Mark the message as read for the client user
:return: true
# File lib/gitter/api/message.rb, line 126 def mark_as_read payload = { "chat" => [id] }.to_json path = "/#{api_prefix}/user/#{client.user.id}/rooms/#{room_id}/unreadItems" client.post path, payload true end
Edit/update a Message's text
The html will be reformated on the server, and returned as part of the data
when returned.
A new instance of Gitter::API::Message
is the turn value
:return: Gitter::API::Message
Parameters¶ ↑
- text (String)
-
New text to update the message record to
# File lib/gitter/api/message.rb, line 115 def update text payload = { "text" => message }.to_json data = client.post "#{api_prefix}/rooms/#{room_id}/chatMessages/#{id}", payload new client, room_id, data end