From 62333c5f39ca42e8a24201e44db670460a081ac2 Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Tue, 25 May 2010 22:21:56 +0200 Subject: [PATCH] Update the command to send a PM originating from the operator/admin that sent it. --- src/core/commands.c | 31 +++++++++++++++++++++++++++++-- src/core/route.c | 2 +- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/core/commands.c b/src/core/commands.c index 44a40ce..ecb21f7 100644 --- a/src/core/commands.c +++ b/src/core/commands.c @@ -412,11 +412,38 @@ static int command_whoip(struct hub_info* hub, struct hub_user* user, struct hub static int command_broadcast(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd) { - struct adc_message* command = adc_msg_construct(ADC_CMD_IMSG, strlen((cmd->message + 12)) + 6); - adc_msg_add_argument(command, (cmd->message + 12)); + size_t offset = 12; +#if USE_OLD_BROADCAST_STYLE + struct adc_message* command = adc_msg_construct(ADC_CMD_IMSG, strlen((cmd->message + offset)) + 6); + adc_msg_add_argument(command, (cmd->message + offset)); route_to_all(hub, command); adc_msg_free(command); return 0; +#else + size_t message_len = strlen(cmd->message + offset); + struct adc_message* command = 0; + char pm_flag[7] = "PM"; + char from_sid[5]; + + memcpy(from_sid, sid_to_string(user->id.sid), sizeof(from_sid)); + memcpy(pm_flag + 2, from_sid, sizeof(from_sid)); + + struct hub_user* target = (struct hub_user*) list_get_first(hub->users->list); + while (target) + { + command = adc_msg_construct(ADC_CMD_DMSG, message_len + 23); + adc_msg_add_argument(command, from_sid); + adc_msg_add_argument(command, sid_to_string(target->id.sid)); + adc_msg_add_argument(command, (cmd->message + offset)); + adc_msg_add_argument(command, pm_flag); + + route_to_user(hub, target, command); + + target = (struct hub_user*) list_get_next(hub->users->list); + adc_msg_free(command); + } + return 0; +#endif } static int command_history(struct hub_info* hub, struct hub_user* user, struct hub_command* cmd) diff --git a/src/core/route.c b/src/core/route.c index 01f071f..1670991 100644 --- a/src/core/route.c +++ b/src/core/route.c @@ -145,7 +145,7 @@ int route_to_all(struct hub_info* hub, struct adc_message* command) /* iterate u route_to_user(hub, user, command); user = (struct hub_user*) list_get_next(hub->users->list); } - + return 0; }