2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2013 Adam <Adam@anope.org>
6 * Copyright (C) 2012-2015 Attila Molnar <attilamolnar@hush.com>
7 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
8 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
10 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
12 * This file is part of InspIRCd. InspIRCd is free software: you can
13 * redistribute it and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation, version 2.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 CmdResult CommandMetadata::Handle(User* srcuser, Params& params)
33 std::string value = params.size() < 3 ? "" : params[2];
34 FOREACH_MOD(OnDecodeMetaData, (NULL,params[1],value));
38 if (params[0][0] == '#')
40 // Channel METADATA has an additional parameter: the channel TS
41 // :22D METADATA #channel 12345 extname :extdata
42 if (params.size() < 3)
43 throw ProtocolException("Insufficient parameters for channel METADATA");
45 Channel* c = ServerInstance->FindChan(params[0]);
49 time_t ChanTS = ServerCommand::ExtractTS(params[1]);
51 // Their TS is newer than ours, discard this command and do not propagate
54 std::string value = params.size() < 4 ? "" : params[3];
56 ExtensionItem* item = ServerInstance->Extensions.GetItem(params[2]);
57 if ((item) && (item->type == ExtensionItem::EXT_CHANNEL))
58 item->FromNetwork(c, value);
59 FOREACH_MOD(OnDecodeMetaData, (c,params[2],value));
63 User* u = ServerInstance->FindUUID(params[0]);
66 ExtensionItem* item = ServerInstance->Extensions.GetItem(params[1]);
67 std::string value = params.size() < 3 ? "" : params[2];
69 if ((item) && (item->type == ExtensionItem::EXT_USER))
70 item->FromNetwork(u, value);
71 FOREACH_MOD(OnDecodeMetaData, (u,params[1],value));
78 CommandMetadata::Builder::Builder(User* user, const std::string& key, const std::string& val)
79 : CmdBuilder("METADATA")
86 CommandMetadata::Builder::Builder(Channel* chan, const std::string& key, const std::string& val)
87 : CmdBuilder("METADATA")
95 CommandMetadata::Builder::Builder(const std::string& key, const std::string& val)
96 : CmdBuilder("METADATA")