mirror of
https://github.com/matrix-construct/construct
synced 2024-12-29 00:44:17 +01:00
LIST: more cleanups
This commit is contained in:
parent
e835592cfc
commit
730b914c17
2 changed files with 19 additions and 25 deletions
|
@ -71,7 +71,6 @@ struct Server;
|
||||||
struct LocalUser;
|
struct LocalUser;
|
||||||
struct AuthRequest;
|
struct AuthRequest;
|
||||||
struct PreClient;
|
struct PreClient;
|
||||||
struct ListClient;
|
|
||||||
struct scache_entry;
|
struct scache_entry;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -270,8 +269,6 @@ struct LocalUser
|
||||||
time_t ratelimit;
|
time_t ratelimit;
|
||||||
unsigned int join_who_credits;
|
unsigned int join_who_credits;
|
||||||
|
|
||||||
struct ListClient *safelist_data;
|
|
||||||
|
|
||||||
char *mangledhost; /* non-NULL if host mangling module loaded and
|
char *mangledhost; /* non-NULL if host mangling module loaded and
|
||||||
applicable to this client */
|
applicable to this client */
|
||||||
|
|
||||||
|
@ -302,14 +299,6 @@ struct PreClient
|
||||||
struct rb_sockaddr_storage lip; /* address of our side of the connection */
|
struct rb_sockaddr_storage lip; /* address of our side of the connection */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ListClient
|
|
||||||
{
|
|
||||||
unsigned int hash_indice;
|
|
||||||
unsigned int users_min, users_max;
|
|
||||||
time_t created_min, created_max, topic_min, topic_max;
|
|
||||||
int operspy;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* status macros.
|
* status macros.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -58,10 +58,16 @@ static void _moddeinit(void);
|
||||||
static int m_list(struct Client *, struct Client *, int, const char **);
|
static int m_list(struct Client *, struct Client *, int, const char **);
|
||||||
static int mo_list(struct Client *, struct Client *, int, const char **);
|
static int mo_list(struct Client *, struct Client *, int, const char **);
|
||||||
|
|
||||||
|
struct ListOptions
|
||||||
|
{
|
||||||
|
unsigned int users_min, users_max;
|
||||||
|
time_t created_min, created_max, topic_min, topic_max;
|
||||||
|
int operspy;
|
||||||
|
};
|
||||||
|
|
||||||
static void list_one_channel(struct Client *source_p, struct Channel *chptr, int visible);
|
static void list_one_channel(struct Client *source_p, struct Channel *chptr, int visible);
|
||||||
|
|
||||||
static void safelist_client_instantiate(struct Client *, struct ListClient *);
|
static void safelist_one_channel(struct Client *source_p, struct Channel *chptr, struct ListOptions *params);
|
||||||
static void safelist_one_channel(struct Client *source_p, struct Channel *chptr);
|
|
||||||
static void safelist_channel_named(struct Client *source_p, const char *name, int operspy);
|
static void safelist_channel_named(struct Client *source_p, const char *name, int operspy);
|
||||||
|
|
||||||
struct Message list_msgtab = {
|
struct Message list_msgtab = {
|
||||||
|
@ -126,7 +132,7 @@ static int m_list(struct Client *client_p, struct Client *source_p, int parc, co
|
||||||
*/
|
*/
|
||||||
static int mo_list(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
static int mo_list(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct ListClient *params;
|
struct ListOptions *params;
|
||||||
char *p;
|
char *p;
|
||||||
char *args = NULL;
|
char *args = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
@ -157,7 +163,7 @@ static int mo_list(struct Client *client_p, struct Client *source_p, int parc, c
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Multiple channels, possibly with parameters. */
|
/* Multiple channels, possibly with parameters. */
|
||||||
params = rb_malloc(sizeof(struct ListClient));
|
params = rb_malloc(sizeof(struct ListOptions));
|
||||||
|
|
||||||
params->users_min = ConfigChannel.displayed_usercount;
|
params->users_min = ConfigChannel.displayed_usercount;
|
||||||
params->users_max = INT_MAX;
|
params->users_max = INT_MAX;
|
||||||
|
@ -251,7 +257,7 @@ static int mo_list(struct Client *client_p, struct Client *source_p, int parc, c
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, global_channel_list.head)
|
RB_DLINK_FOREACH(ptr, global_channel_list.head)
|
||||||
{
|
{
|
||||||
safelist_one_channel(client_p, ptr->data);
|
safelist_one_channel(client_p, ptr->data, params);
|
||||||
|
|
||||||
if (rb_linebuf_len(&client_p->localClient->buf_sendq) > sendq_limit)
|
if (rb_linebuf_len(&client_p->localClient->buf_sendq) > sendq_limit)
|
||||||
{
|
{
|
||||||
|
@ -357,31 +363,30 @@ static void safelist_channel_named(struct Client *source_p, const char *name, in
|
||||||
* side effects - a channel is listed if it meets the
|
* side effects - a channel is listed if it meets the
|
||||||
* requirements
|
* requirements
|
||||||
*/
|
*/
|
||||||
static void safelist_one_channel(struct Client *source_p, struct Channel *chptr)
|
static void safelist_one_channel(struct Client *source_p, struct Channel *chptr, struct ListOptions *params)
|
||||||
{
|
{
|
||||||
struct ListClient *safelist_data = source_p->localClient->safelist_data;
|
|
||||||
int visible;
|
int visible;
|
||||||
|
|
||||||
visible = !SecretChannel(chptr) || IsMember(source_p, chptr);
|
visible = !SecretChannel(chptr) || IsMember(source_p, chptr);
|
||||||
if (!visible && !safelist_data->operspy)
|
if (!visible && !params->operspy)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((unsigned int)chptr->members.length < safelist_data->users_min
|
if ((unsigned int)chptr->members.length < params->users_min
|
||||||
|| (unsigned int)chptr->members.length > safelist_data->users_max)
|
|| (unsigned int)chptr->members.length > params->users_max)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (safelist_data->topic_min && chptr->topic_time < safelist_data->topic_min)
|
if (params->topic_min && chptr->topic_time < params->topic_min)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If a topic TS is provided, don't show channels without a topic set. */
|
/* If a topic TS is provided, don't show channels without a topic set. */
|
||||||
if (safelist_data->topic_max && (chptr->topic_time > safelist_data->topic_max
|
if (params->topic_max && (chptr->topic_time > params->topic_max
|
||||||
|| chptr->topic_time == 0))
|
|| chptr->topic_time == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (safelist_data->created_min && chptr->channelts < safelist_data->created_min)
|
if (params->created_min && chptr->channelts < params->created_min)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (safelist_data->created_max && chptr->channelts > safelist_data->created_max)
|
if (params->created_max && chptr->channelts > params->created_max)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
list_one_channel(source_p, chptr, visible);
|
list_one_channel(source_p, chptr, visible);
|
||||||
|
|
Loading…
Reference in a new issue