1 // Support for blog rooms
3 // Copyright (c) 1999-2023 by the citadel.org team
5 // This program is open source software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as published
7 // by the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "../../sysdep.h"
28 #include <sys/types.h>
33 #include <libcitadel.h>
34 #include "../../citadel_defs.h"
35 #include "../../server.h"
36 #include "../../citserver.h"
37 #include "../../support.h"
38 #include "../../config.h"
39 #include "../../control.h"
40 #include "../../user_ops.h"
41 #include "../../database.h"
42 #include "../../msgbase.h"
43 #include "../../internet_addressing.h"
44 #include "../../serv_vcard.h"
45 #include "../../citadel_ldap.h"
46 #include "../../ctdl_module.h"
48 // Pre-save hook for saving a message in a blog room.
49 // (Do we want to only do this for top-level messages?)
50 int blog_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
52 // Only run this hook for blog rooms
53 if (CC->room.QRdefaultview != VIEW_BLOG) {
57 // If the message doesn't have an EUID, give it one.
58 if (CM_IsEmpty(msg, eExclusiveID)) {
61 CM_SetField(msg, eExclusiveID, uuid);
64 // We also want to define a maximum length, whether we generated it or not.
65 CM_CutFieldAt(msg, eExclusiveID, BLOG_EUIDBUF_SIZE - 1);
67 // Now allow the save to complete.
72 // Initialization function, called from modules_init.c
73 char *ctdl_module_init_blog(void) {
75 CtdlRegisterMessageHook(blog_upload_beforesave, EVT_BEFORESAVE);
78 // return our module id for the log