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
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;
message.from = null;
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 wrapWidth = state.environment.get('wrapWidth');
message.length = message.message.length;
message.breakpoints = findBreakpoints(message.message);
message.length = message.content.length;
message.breakpoints = findBreakpoints(message.content);
message.height = messageHeight(message, wrapWidth, charWidth, 6 * charWidth);
message.message = linkify(message.message);
message.content = linkify(message.content);
return message;
}
@ -40,7 +40,7 @@ export function updateMessageHeight() {
});
}
export function sendMessage(message, to, server) {
export function sendMessage(content, to, server) {
return (dispatch, getState) => {
const state = getState();
@ -48,14 +48,14 @@ export function sendMessage(message, to, server) {
type: actions.SEND_MESSAGE,
message: initMessage({
from: state.servers.getIn([server, 'nick']),
message,
content,
to,
server,
time: timestamp()
}, state),
socket: {
type: 'chat',
data: { message, to, server }
type: 'message',
data: { content, to, server }
}
});
};
@ -91,17 +91,17 @@ export function broadcast(message, server, channels) {
return addMessages(channels.map(channel => ({
server,
to: channel,
message,
content: message,
type: 'info'
})));
}
export function inform(message, server, channel) {
if (Array.isArray(message)) {
return addMessages(message.map(msg => ({
return addMessages(message.map(line => ({
server,
to: channel,
message: msg,
content: line,
type: 'info'
})));
}
@ -109,7 +109,7 @@ export function inform(message, server, channel) {
return addMessage({
server,
to: channel,
message,
content: message,
type: 'info'
});
}

View File

@ -60,7 +60,7 @@ export default createCommandMiddleware(COMMAND, {
dispatch(addMessage({
server,
to: channel,
message: topic
content: topic
}));
} else {
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}>
{' '}{message.from}
</span>
}{' '}{message.message}
}{' '}{message.content}
</p>
);
}

View File

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

View File

@ -70,7 +70,7 @@ export default function handleSocket(socket, { dispatch, getState }) {
dispatch(addMessages(content.map(line => ({
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) {
message := Chat{
message := Message{
Server: i.client.Host,
From: msg.Nick,
Message: msg.LastParam(),
Content: msg.LastParam(),
}
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)
}
i.session.sendJSON("pm", Chat{
i.session.sendJSON("pm", Message{
Server: i.client.Host,
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"},
})
checkResponse(t, "message", Chat{
checkResponse(t, "message", Message{
Server: "host.com",
From: "nick",
To: "#chan",
Message: "the message",
Content: "the message",
}, res)
res = dispatchMessage(&irc.Message{
@ -143,10 +143,10 @@ func TestHandleIRCMessage(t *testing.T) {
Params: []string{"nick", "the message"},
})
checkResponse(t, "pm", Chat{
checkResponse(t, "pm", Message{
Server: "host.com",
From: "someone",
Message: "the message",
Content: "the message",
}, res)
}
@ -176,10 +176,10 @@ func TestHandleIRCWelcome(t *testing.T) {
New: "nick",
}, <-res)
checkResponse(t, "pm", Chat{
checkResponse(t, "pm", Message{
Server: "host.com",
From: "nick",
Message: "some text",
Content: "some text",
}, <-res)
}

View File

@ -60,11 +60,11 @@ type Quit struct {
Reason string `json:"reason,omitempty"`
}
type Chat struct {
type Message struct {
Server string `json:"server"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Message string `json:"message"`
Content string `json:"content"`
}
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{}) {
s.sendJSON("print", Chat{
s.sendJSON("print", Message{
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) {
var data Chat
func (h *wsHandler) message(b []byte) {
var data Message
json.Unmarshal(b, &data)
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,
"part": h.part,
"quit": h.quit,
"chat": h.chat,
"message": h.message,
"nick": h.nick,
"invite": h.invite,
"kick": h.kick,