mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-09 14:23:12 +02:00
Again a fix for JSON logging, so object_detail_level has same result as 6.0.6.
This also changes the Detail level (object_detail_level) for the channel.* calls. See https://www.unrealircd.org/docs/JSON-RPC:Channel_Object for latest info. In short: at level 5, we now still hide the members.user.channels because in general that object is not useful. When you do a channel.* API call you want a list of users in the channel, and don't really care about what other channels the user is in, other than the channel you already know.
This commit is contained in:
+11
-3
@@ -181,7 +181,9 @@ void json_expand_client_security_groups(json_t *parent, Client *client)
|
||||
|
||||
/* detail=0: only name, id
|
||||
* detail=1: only name, id, hostname, ip, details, geoip
|
||||
* detail=2: everything
|
||||
* detail=2: everything, except 'channels'
|
||||
* detail=3: everything, with 'channels' being a max 384 character string (meant for JSON logging only)
|
||||
* detail=4: everything, with 'channels' object (full).
|
||||
*/
|
||||
void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
{
|
||||
@@ -281,14 +283,20 @@ void json_expand_client(json_t *j, const char *key, Client *client, int detail)
|
||||
str = get_operclass(client);
|
||||
if (str)
|
||||
json_object_set_new(user, "operclass", json_string_unreal(str));
|
||||
if (client->user->channel)
|
||||
/* For detail>2 we will include the channels.
|
||||
* Even if the user is on 0 channels we include "channels":[]
|
||||
* so it is clear that the user is on 0 channels and it is
|
||||
* not because of low detail level that channels are skipped.
|
||||
*/
|
||||
if (detail > 2)
|
||||
{
|
||||
Membership *m;
|
||||
int cnt = 0;
|
||||
int len = 0;
|
||||
json_t *channels = json_array();
|
||||
json_object_set_new(user, "channels", channels);
|
||||
if (detail == 0)
|
||||
|
||||
if (detail == 3)
|
||||
{
|
||||
/* Short format, mainly for JSON logging */
|
||||
for (m = client->user->channel; m; m = m->next)
|
||||
|
||||
@@ -1477,7 +1477,7 @@ void do_unreal_log_internal(LogLevel loglevel, const char *subsystem, const char
|
||||
* details later on.
|
||||
*/
|
||||
if (client)
|
||||
json_expand_client(j_details, "client", client, 99);
|
||||
json_expand_client(j_details, "client", client, 3);
|
||||
/* Additional details (if any) */
|
||||
while ((d = va_arg(vl, LogData *)))
|
||||
{
|
||||
@@ -1493,7 +1493,7 @@ void do_unreal_log_internal(LogLevel loglevel, const char *subsystem, const char
|
||||
json_object_set_new(j_details, d->key, json_null());
|
||||
break;
|
||||
case LOG_FIELD_CLIENT:
|
||||
json_expand_client(j_details, d->key, d->value.client, 99);
|
||||
json_expand_client(j_details, d->key, d->value.client, 3);
|
||||
break;
|
||||
case LOG_FIELD_CHANNEL:
|
||||
json_expand_channel(j_details, d->key, d->value.channel, 1);
|
||||
|
||||
Reference in New Issue
Block a user