1 // Support for blog rooms
3 // Copyright (c) 1999-2024 by the citadel.org team
5 // This program is open source software. Use, duplication, or disclosure
6 // is subject to the terms of the GNU General Public License, version 3.
8 #include "../../sysdep.h"
17 #include <sys/types.h>
22 #include <libcitadel.h>
23 #include "../../citadel_defs.h"
24 #include "../../server.h"
25 #include "../../citserver.h"
26 #include "../../support.h"
27 #include "../../config.h"
28 #include "../../control.h"
29 #include "../../user_ops.h"
30 #include "../../database.h"
31 #include "../../msgbase.h"
32 #include "../../internet_addressing.h"
33 #include "../../serv_vcard.h"
34 #include "../../citadel_ldap.h"
35 #include "../../ctdl_module.h"
37 // Pre-save hook for saving a message in a blog room.
38 // (Do we want to only do this for top-level messages?)
39 int blog_upload_beforesave(struct CtdlMessage *msg, struct recptypes *recp) {
41 // Only run this hook for blog rooms
42 if (CC->room.QRdefaultview != VIEW_BLOG) {
46 // If the message doesn't have an EUID, give it one.
47 if (CM_IsEmpty(msg, eExclusiveID)) {
50 CM_SetField(msg, eExclusiveID, uuid);
53 // We also want to define a maximum length, whether we generated it or not.
54 CM_CutFieldAt(msg, eExclusiveID, BLOG_EUIDBUF_SIZE - 1);
56 // Now allow the save to complete.
61 // Initialization function, called from modules_init.c
62 char *ctdl_module_init_blog(void) {
64 CtdlRegisterMessageHook(blog_upload_beforesave, EVT_BEFORESAVE);
67 // return our module id for the log