Add unrealircd.org/issued-by if using RPC call channel.set_mode

This also changes the set_channel_mode() function to have
an extra arguments MessageTag *mtags (2nd parameter).
This commit is contained in:
Bram Matthys 2023-04-02 12:06:52 +02:00
parent 0b8f0deb05
commit 50c3ed2c24
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98
5 changed files with 10 additions and 7 deletions

View file

@ -750,7 +750,7 @@ extern MODVAR int (*can_join)(Client *client, Channel *channel, const char *key,
extern MODVAR void (*do_mode)(Channel *channel, Client *client, MessageTag *mtags, int parc, const char *parv[], time_t sendts, int samode);
extern MODVAR MultiLineMode *(*set_mode)(Channel *channel, Client *cptr, int parc, const char *parv[], u_int *pcount,
char pvar[MAXMODEPARAMS][MODEBUFLEN + 3]);
extern MODVAR void (*set_channel_mode)(Channel *channel, const char *modes, const char *parameters);
extern MODVAR void (*set_channel_mode)(Channel *channel, MessageTag *mtags, const char *modes, const char *parameters);
extern MODVAR void (*set_channel_topic)(Client *client, Channel *channel, MessageTag *recv_mtags, const char *topic, const char *set_by, time_t set_at);
extern MODVAR void (*cmd_umode)(Client *, MessageTag *, int, const char **);
extern MODVAR int (*register_user)(Client *client);

View file

@ -40,7 +40,7 @@ int (*can_join)(Client *client, Channel *channel, const char *key, char **errmsg
void (*do_mode)(Channel *channel, Client *client, MessageTag *mtags, int parc, const char *parv[], time_t sendts, int samode);
MultiLineMode *(*set_mode)(Channel *channel, Client *client, int parc, const char *parv[], u_int *pcount,
char pvar[MAXMODEPARAMS][MODEBUFLEN + 3]);
void (*set_channel_mode)(Channel *channel, const char *modes, const char *parameters);
void (*set_channel_mode)(Channel *channel, MessageTag *mtags, const char *modes, const char *parameters);
void (*set_channel_topic)(Client *client, Channel *channel, MessageTag *recv_mtags, const char *topic, const char *set_by, time_t set_at);
void (*cmd_umode)(Client *client, MessageTag *mtags, int parc, const char *parv[]);
int (*register_user)(Client *client);

View file

@ -537,7 +537,7 @@ int read_channeldb(void)
safe_strdup(channel->topic_nick, topic_nick);
channel->topic_time = topic_time;
safe_strdup(channel->mode_lock, mode_lock);
set_channel_mode(channel, modes1, modes2);
set_channel_mode(channel, NULL, modes1, modes2);
R_SAFE(read_listmode(db, &channel->banlist));
R_SAFE(read_listmode(db, &channel->exlist));
R_SAFE(read_listmode(db, &channel->invexlist));

View file

@ -38,7 +38,7 @@ CMD_FUNC(cmd_mlock);
void _do_mode(Channel *channel, Client *client, MessageTag *recv_mtags, int parc, const char *parv[], time_t sendts, int samode);
MultiLineMode *_set_mode(Channel *channel, Client *client, int parc, const char *parv[], u_int *pcount,
char pvar[MAXMODEPARAMS][MODEBUFLEN + 3]);
void _set_channel_mode(Channel *channel, const char *modes, const char *parameters);
void _set_channel_mode(Channel *channel, MessageTag *mtags, const char *modes, const char *parameters);
CMD_FUNC(_cmd_umode);
/* local: */
@ -1545,7 +1545,7 @@ int list_mode_request(Client *client, Channel *channel, const char *req)
return 1; /* handled */
}
void _set_channel_mode(Channel *channel, const char *modes, const char *parameters)
void _set_channel_mode(Channel *channel, MessageTag *mtags, const char *modes, const char *parameters)
{
char buf[512];
char *p, *param;
@ -1561,7 +1561,7 @@ void _set_channel_mode(Channel *channel, const char *modes, const char *paramete
myparv[myparc] = NULL;
SetULine(&me); // hack for crash.. set ulined so no access checks.
do_mode(channel, &me, NULL, myparc, (const char **)myparv, 0, 0);
do_mode(channel, &me, mtags, myparc, (const char **)myparv, 0, 0);
ClearULine(&me); // and clear it again..
for (i = 0; i < myparc; i++)

View file

@ -137,6 +137,7 @@ void rpc_channel_set_mode(Client *client, json_t *request, json_t *params)
{
json_t *result, *item;
const char *channelname, *modes, *parameters;
MessageTag *mtags = NULL;
Channel *channel;
REQUIRE_PARAM_STRING("channel", channelname);
@ -149,7 +150,9 @@ void rpc_channel_set_mode(Client *client, json_t *request, json_t *params)
return;
}
set_channel_mode(channel, modes, parameters);
mtag_add_issued_by(&mtags, client, NULL);
set_channel_mode(channel, mtags, modes, parameters);
safe_free_message_tags(mtags);
/* Simply return success */
result = json_boolean(1);