Rename message.message to message.content

This commit is contained in:
Ken-Håvard Lieng 2017-04-17 22:36:37 +02:00
parent c4609574c7
commit ebee2746d6
11 changed files with 55 additions and 55 deletions

File diff suppressed because one or more lines are too long

View File

@ -12,22 +12,22 @@ function initMessage(message, state) {
} }
// Collapse multiple adjacent spaces into a single one // Collapse multiple adjacent spaces into a single one
message.message = message.message.replace(/\s\s+/g, ' '); message.content = message.content.replace(/\s\s+/g, ' ');
if (message.message.indexOf('\x01ACTION') === 0) { if (message.content.indexOf('\x01ACTION') === 0) {
const from = message.from; const from = message.from;
message.from = null; message.from = null;
message.type = 'action'; message.type = 'action';
message.message = from + message.message.slice(7, -1); message.content = from + message.content.slice(7, -1);
} }
const charWidth = state.environment.get('charWidth'); const charWidth = state.environment.get('charWidth');
const wrapWidth = state.environment.get('wrapWidth'); const wrapWidth = state.environment.get('wrapWidth');
message.length = message.message.length; message.length = message.content.length;
message.breakpoints = findBreakpoints(message.message); message.breakpoints = findBreakpoints(message.content);
message.height = messageHeight(message, wrapWidth, charWidth, 6 * charWidth); message.height = messageHeight(message, wrapWidth, charWidth, 6 * charWidth);
message.message = linkify(message.message); message.content = linkify(message.content);
return message; return message;
} }
@ -40,7 +40,7 @@ export function updateMessageHeight() {
}); });
} }
export function sendMessage(message, to, server) { export function sendMessage(content, to, server) {
return (dispatch, getState) => { return (dispatch, getState) => {
const state = getState(); const state = getState();
@ -48,14 +48,14 @@ export function sendMessage(message, to, server) {
type: actions.SEND_MESSAGE, type: actions.SEND_MESSAGE,
message: initMessage({ message: initMessage({
from: state.servers.getIn([server, 'nick']), from: state.servers.getIn([server, 'nick']),
message, content,
to, to,
server, server,
time: timestamp() time: timestamp()
}, state), }, state),
socket: { socket: {
type: 'chat', type: 'message',
data: { message, to, server } data: { content, to, server }
} }
}); });
}; };
@ -91,17 +91,17 @@ export function broadcast(message, server, channels) {
return addMessages(channels.map(channel => ({ return addMessages(channels.map(channel => ({
server, server,
to: channel, to: channel,
message, content: message,
type: 'info' type: 'info'
}))); })));
} }
export function inform(message, server, channel) { export function inform(message, server, channel) {
if (Array.isArray(message)) { if (Array.isArray(message)) {
return addMessages(message.map(msg => ({ return addMessages(message.map(line => ({
server, server,
to: channel, to: channel,
message: msg, content: line,
type: 'info' type: 'info'
}))); })));
} }
@ -109,7 +109,7 @@ export function inform(message, server, channel) {
return addMessage({ return addMessage({
server, server,
to: channel, to: channel,
message, content: message,
type: 'info' type: 'info'
}); });
} }

View File

@ -60,7 +60,7 @@ export default createCommandMiddleware(COMMAND, {
dispatch(addMessage({ dispatch(addMessage({
server, server,
to: channel, to: channel,
message: topic content: topic
})); }));
} else { } else {
dispatch(inform('No topic set', server, channel)); dispatch(inform('No topic set', server, channel));

View File

@ -24,7 +24,7 @@ export default class Message extends PureComponent {
<span className="message-sender" onClick={this.handleSenderClick}> <span className="message-sender" onClick={this.handleSenderClick}>
{' '}{message.from} {' '}{message.from}
</span> </span>
}{' '}{message.message} }{' '}{message.content}
</p> </p>
); );
} }

View File

@ -8,7 +8,7 @@ const Message = Record({
server: null, server: null,
from: null, from: null,
to: null, to: null,
message: '', content: '',
time: null, time: null,
type: null, type: null,
channel: false, channel: false,

View File

@ -70,7 +70,7 @@ export default function handleSocket(socket, { dispatch, getState }) {
dispatch(addMessages(content.map(line => ({ dispatch(addMessages(content.map(line => ({
server, server,
to: server, to: server,
message: line content: line
})))); }))));
}, },

View File

@ -121,10 +121,10 @@ func (i *ircHandler) mode(msg *irc.Message) {
} }
func (i *ircHandler) message(msg *irc.Message) { func (i *ircHandler) message(msg *irc.Message) {
message := Chat{ message := Message{
Server: i.client.Host, Server: i.client.Host,
From: msg.Nick, From: msg.Nick,
Message: msg.LastParam(), Content: msg.LastParam(),
} }
if msg.Params[0] == i.client.GetNick() { if msg.Params[0] == i.client.GetNick() {
@ -159,10 +159,10 @@ func (i *ircHandler) info(msg *irc.Message) {
go i.session.user.SetNick(msg.Params[0], i.client.Host) go i.session.user.SetNick(msg.Params[0], i.client.Host)
} }
i.session.sendJSON("pm", Chat{ i.session.sendJSON("pm", Message{
Server: i.client.Host, Server: i.client.Host,
From: msg.Nick, From: msg.Nick,
Message: strings.Join(msg.Params[1:], " "), Content: strings.Join(msg.Params[1:], " "),
}) })
} }

View File

@ -130,11 +130,11 @@ func TestHandleIRCMessage(t *testing.T) {
Params: []string{"#chan", "the message"}, Params: []string{"#chan", "the message"},
}) })
checkResponse(t, "message", Chat{ checkResponse(t, "message", Message{
Server: "host.com", Server: "host.com",
From: "nick", From: "nick",
To: "#chan", To: "#chan",
Message: "the message", Content: "the message",
}, res) }, res)
res = dispatchMessage(&irc.Message{ res = dispatchMessage(&irc.Message{
@ -143,10 +143,10 @@ func TestHandleIRCMessage(t *testing.T) {
Params: []string{"nick", "the message"}, Params: []string{"nick", "the message"},
}) })
checkResponse(t, "pm", Chat{ checkResponse(t, "pm", Message{
Server: "host.com", Server: "host.com",
From: "someone", From: "someone",
Message: "the message", Content: "the message",
}, res) }, res)
} }
@ -176,10 +176,10 @@ func TestHandleIRCWelcome(t *testing.T) {
New: "nick", New: "nick",
}, <-res) }, <-res)
checkResponse(t, "pm", Chat{ checkResponse(t, "pm", Message{
Server: "host.com", Server: "host.com",
From: "nick", From: "nick",
Message: "some text", Content: "some text",
}, <-res) }, <-res)
} }

View File

@ -60,11 +60,11 @@ type Quit struct {
Reason string `json:"reason,omitempty"` Reason string `json:"reason,omitempty"`
} }
type Chat struct { type Message struct {
Server string `json:"server"` Server string `json:"server"`
From string `json:"from,omitempty"` From string `json:"from,omitempty"`
To string `json:"to,omitempty"` To string `json:"to,omitempty"`
Message string `json:"message"` Content string `json:"content"`
} }
type Topic struct { type Topic struct {

View File

@ -128,9 +128,9 @@ func (s *Session) sendError(err error, server string) {
} }
func (s *Session) print(server string, a ...interface{}) { func (s *Session) print(server string, a ...interface{}) {
s.sendJSON("print", Chat{ s.sendJSON("print", Message{
Server: server, Server: server,
Message: fmt.Sprintln(a...), Content: fmt.Sprintln(a...),
}) })
} }

View File

@ -156,12 +156,12 @@ func (h *wsHandler) quit(b []byte) {
} }
} }
func (h *wsHandler) chat(b []byte) { func (h *wsHandler) message(b []byte) {
var data Chat var data Message
json.Unmarshal(b, &data) json.Unmarshal(b, &data)
if i, ok := h.session.getIRC(data.Server); ok { if i, ok := h.session.getIRC(data.Server); ok {
i.Privmsg(data.To, data.Message) i.Privmsg(data.To, data.Content)
} }
} }
@ -257,7 +257,7 @@ func (h *wsHandler) initHandlers() {
"join": h.join, "join": h.join,
"part": h.part, "part": h.part,
"quit": h.quit, "quit": h.quit,
"chat": h.chat, "message": h.message,
"nick": h.nick, "nick": h.nick,
"invite": h.invite, "invite": h.invite,
"kick": h.kick, "kick": h.kick,