Removed an unused parameter from CtdlSubmitMsg(). Why was it even there?
[citadel.git] / citadel / modules / instmsg / serv_instmsg.c
index b150a9167dcdbb701288d0153ec18a04dfb2e6f4..a774c61f2f4d030160bf0c7bc39e550b2c7b7120 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This module handles instant messaging between users.
  * 
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2020 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 3.
@@ -110,12 +110,9 @@ void log_instant_message(struct CitContext *me, struct CitContext *them, char *m
                this_im->conversation = NewStrBuf();
                this_im->next = imlist;
                imlist = this_im;
-               StrBufAppendBufPlain(this_im->conversation, HKEY(
-                       "<html><body>\r\n"
-                       ), 0);
+               StrBufAppendBufPlain(this_im->conversation, HKEY("<html><body>\r\n"), 0);
        }
 
-
        /* Since it's possible for this function to get called more than once if a user is logged
         * in on multiple sessions, we use the message's serial number to keep track of whether
         * we've already logged it.
@@ -152,7 +149,6 @@ void delete_instant_messages(void) {
 }
 
 
-
 /*
  * Retrieve instant messages
  */
@@ -188,6 +184,7 @@ void cmd_gexp(char *argbuf) {
        free(ptr);
 }
 
+
 /*
  * Asynchronously deliver instant messages
  */
@@ -202,6 +199,7 @@ void cmd_gexp_async(void) {
        cprintf("%d instant msg\n", ASYNC_MSG + ASYNC_GEXP);
 }
 
+
 /*
  * Back end support function for send_instant_message() and company
  */
@@ -227,8 +225,6 @@ void add_xmsg_to_context(struct CitContext *ccptr, struct ExpressMessage *newmsg
 }
 
 
-
-
 /* 
  * This is the back end to the instant message sending function.  
  * Returns the number of users to which the message was sent.
@@ -239,7 +235,6 @@ int send_instant_message(char *lun, char *lem, char *x_user, char *x_msg)
        int message_sent = 0;           /* number of successful sends */
        struct CitContext *ccptr;
        struct ExpressMessage *newmsg = NULL;
-       char *un;
        int do_send = 0;                /* 1 = send message; 0 = only check for valid recipient */
        static int serial_number = 0;   /* this keeps messages from getting logged twice */
 
@@ -252,14 +247,7 @@ int send_instant_message(char *lun, char *lem, char *x_user, char *x_msg)
        ++serial_number;
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
 
-               if (ccptr->fake_username[0]) {
-                       un = ccptr->fake_username;
-               }
-               else {
-                       un = ccptr->user.fullname;
-               }
-
-               if ( ((!strcasecmp(un, x_user))
+               if ( ((!strcasecmp(ccptr->user.fullname, x_user))
                    || (!strcasecmp(x_user, "broadcast")))
                    && (ccptr->can_receive_im)
                    && ((ccptr->disable_exp == 0)
@@ -289,6 +277,7 @@ int send_instant_message(char *lun, char *lem, char *x_user, char *x_msg)
        return (message_sent);
 }
 
+
 /*
  * send instant messages
  */
@@ -297,7 +286,6 @@ void cmd_sexp(char *argbuf)
        int message_sent = 0;
        char x_user[USERNAME_SIZE];
        char x_msg[1024];
-       char *lun;
        char *lem;
        char *x_big_msgbuf = NULL;
 
@@ -305,12 +293,8 @@ void cmd_sexp(char *argbuf)
                cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
                return;
        }
-       if (CC->fake_username[0])
-               lun = CC->fake_username;
-       else
-               lun = CC->user.fullname;
 
-       lem = CC->cs_inet_email;
+       lem = CC->cs_principal_id;
 
        extract_token(x_user, argbuf, 0, '|', sizeof x_user);
        extract_token(x_msg, argbuf, 1, '|', sizeof x_msg);
@@ -326,7 +310,7 @@ void cmd_sexp(char *argbuf)
        }
        /* This loop handles text-transfer pages */
        if (!strcmp(x_msg, "-")) {
-               message_sent = PerformXmsgHooks(lun, lem, x_user, "");
+               message_sent = PerformXmsgHooks(CC->user.fullname, lem, x_user, "");
                if (message_sent == 0) {
                        if (CtdlGetUser(NULL, x_user))
                                cprintf("%d '%s' does not exist.\n",
@@ -350,29 +334,32 @@ void cmd_sexp(char *argbuf)
                                strcat(x_big_msgbuf, "\n");
                        strcat(x_big_msgbuf, x_msg);
                }
-               PerformXmsgHooks(lun, lem, x_user, x_big_msgbuf);
+               PerformXmsgHooks(CC->user.fullname, lem, x_user, x_big_msgbuf);
                free(x_big_msgbuf);
 
                /* This loop handles inline pages */
        } else {
-               message_sent = PerformXmsgHooks(lun, lem, x_user, x_msg);
+               message_sent = PerformXmsgHooks(CC->user.fullname, lem, x_user, x_msg);
 
                if (message_sent > 0) {
-                       if (!IsEmptyStr(x_msg))
+                       if (!IsEmptyStr(x_msg)) {
                                cprintf("%d Message sent", CIT_OK);
-                       else
+                       }
+                       else {
                                cprintf("%d Ok to send message", CIT_OK);
-                       if (message_sent > 1)
+                       }
+                       if (message_sent > 1) {
                                cprintf(" to %d users", message_sent);
+                       }
                        cprintf(".\n");
                } else {
-                       if (CtdlGetUser(NULL, x_user))
-                               cprintf("%d '%s' does not exist.\n",
-                                               ERROR + NO_SUCH_USER, x_user);
-                       else
-                               cprintf("%d '%s' is not logged in "
-                                               "or is not accepting pages.\n",
+                       if (CtdlGetUser(NULL, x_user)) {
+                               cprintf("%d '%s' does not exist.\n", ERROR + NO_SUCH_USER, x_user);
+                       }
+                       else {
+                               cprintf("%d '%s' is not logged in or is not accepting instant messages.\n",
                                                ERROR + RESOURCE_NOT_OPEN, x_user);
+                       }
                }
 
 
@@ -380,7 +367,6 @@ void cmd_sexp(char *argbuf)
 }
 
 
-
 /*
  * Enter or exit paging-disabled mode
  */
@@ -457,10 +443,11 @@ void flush_individual_conversation(struct imlog *im) {
        FullMsgBuf = NewStrBufPlain(NULL, StrLength(im->conversation) + 100);
 
        StrBufAppendBufPlain(FullMsgBuf, HKEY(
-                       "Content-type: text/html; charset=UTF-8\r\n"
-                       "Content-Transfer-Encoding: quoted-printable\r\n"
-                       "\r\n"
-                       ), 0);
+               "Content-type: text/html; charset=UTF-8\r\n"
+               "Content-Transfer-Encoding: quoted-printable\r\n"
+               "\r\n"
+               ), 0
+       );
        StrBufAppendBuf (FullMsgBuf, MsgBuf, 0);
        FreeStrBuf(&MsgBuf);
 
@@ -479,7 +466,6 @@ void flush_individual_conversation(struct imlog *im) {
        }
 
        CM_SetField(msg, eOriginalRoom, HKEY(PAGELOGROOM));
-       CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
        CM_SetAsFieldSB(msg, eMesageText, &FullMsgBuf); /* we own this memory now */
 
        /* Start with usernums[1] because it's guaranteed to be higher than usernums[0],
@@ -493,7 +479,7 @@ void flush_individual_conversation(struct imlog *im) {
         */
        snprintf(roomname, sizeof roomname, "%010ld.%s", im->usernums[1], PAGELOGROOM);
        CtdlCreateRoom(roomname, 5, "", 0, 1, 1, VIEW_BBS);
-       msgnum = CtdlSubmitMsg(msg, NULL, roomname, 0);
+       msgnum = CtdlSubmitMsg(msg, NULL, roomname);
        CM_Free(msg);
 
        /* If there is a valid user number in usernums[0], save a copy for them too. */