mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added reason to role/affiliation changes
This commit is contained in:
parent
3790b16299
commit
67755ca74d
@ -348,21 +348,21 @@ static struct cmd_t command_defs[] =
|
|||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
{ "/affiliation",
|
{ "/affiliation",
|
||||||
cmd_affiliation, parse_args, 1, 3, NULL,
|
cmd_affiliation, parse_args_with_freetext, 1, 4, NULL,
|
||||||
{ "/affiliation set|list [affiliation] [jid]", "Manage room affiliations.",
|
{ "/affiliation set|list [affiliation] [jid] [reason]", "Manage room affiliations.",
|
||||||
{ "/affiliation set|list [affiliation] [jid]",
|
{ "/affiliation set|list [affiliation] [jid] [reason]",
|
||||||
"-----------------------------------------",
|
"--------------------------------------------------",
|
||||||
"set affiliation jid - Set the affiliation of user with jid.",
|
"set affiliation jid [reason]- Set the affiliation of user with jid, with an optional reason.",
|
||||||
"list [affiliation] - List all users with the specified affiliation, or all if none specified.",
|
"list [affiliation] - List all users with the specified affiliation, or all if none specified.",
|
||||||
"The affiliation may be one of owner, admin, member, outcast or none.",
|
"The affiliation may be one of owner, admin, member, outcast or none.",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
{ "/role",
|
{ "/role",
|
||||||
cmd_role, parse_args, 1, 3, NULL,
|
cmd_role, parse_args_with_freetext, 1, 4, NULL,
|
||||||
{ "/role set|list [role] [nick]", "Manage room roles.",
|
{ "/role set|list [role] [nick] [reason]", "Manage room roles.",
|
||||||
{ "/role set|list [role] [nick]",
|
{ "/role set|list [role] [nick] [reason]",
|
||||||
"----------------------------",
|
"-------------------------------------",
|
||||||
"set role nick - Set the role of occupant with nick.",
|
"set role nick [reason] - Set the role of occupant with nick, with an optional reason.",
|
||||||
"list [role] - List all occupants with the specified role, or all if none specified.",
|
"list [role] - List all occupants with the specified role, or all if none specified.",
|
||||||
"The role may be one of moderator, participant, visitor or none.",
|
"The role may be one of moderator, participant, visitor or none.",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
@ -667,8 +667,8 @@ handle_ping_error_result(const char * const from, const char * const error)
|
|||||||
|
|
||||||
void
|
void
|
||||||
handle_muc_self_online(const char * const room, const char * const nick, gboolean config_required,
|
handle_muc_self_online(const char * const room, const char * const nick, gboolean config_required,
|
||||||
const char * const role, const char * const affiliation, const char * const jid, const char * const show,
|
const char * const role, const char * const affiliation, const char * const actor, const char * const reason,
|
||||||
const char * const status)
|
const char * const jid, const char * const show, const char * const status)
|
||||||
{
|
{
|
||||||
muc_roster_add(room, nick, jid, role, affiliation, show, status);
|
muc_roster_add(room, nick, jid, role, affiliation, show, status);
|
||||||
char *old_role = muc_role_str(room);
|
char *old_role = muc_role_str(room);
|
||||||
@ -721,15 +721,15 @@ handle_muc_self_online(const char * const room, const char * const nick, gboolea
|
|||||||
} else {
|
} else {
|
||||||
// both changed
|
// both changed
|
||||||
if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) {
|
if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) {
|
||||||
ui_room_role_and_affiliation_change(room, role, affiliation);
|
ui_room_role_and_affiliation_change(room, role, affiliation, actor, reason);
|
||||||
|
|
||||||
// role changed
|
// role changed
|
||||||
} else if (g_strcmp0(role, old_role) != 0) {
|
} else if (g_strcmp0(role, old_role) != 0) {
|
||||||
ui_room_role_change(room, role);
|
ui_room_role_change(room, role, actor, reason);
|
||||||
|
|
||||||
// affiliation changed
|
// affiliation changed
|
||||||
} else if (g_strcmp0(affiliation, old_affiliation) != 0) {
|
} else if (g_strcmp0(affiliation, old_affiliation) != 0) {
|
||||||
ui_room_affiliation_change(room, affiliation);
|
ui_room_affiliation_change(room, affiliation, actor, reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,8 +111,8 @@ void handle_room_configuration_form_error(const char * const from, const char *
|
|||||||
void handle_room_config_submit_result(const char * const room);
|
void handle_room_config_submit_result(const char * const room);
|
||||||
void handle_room_config_submit_result_error(const char * const room, const char * const message);
|
void handle_room_config_submit_result_error(const char * const room, const char * const message);
|
||||||
void handle_muc_self_online(const char * const room, const char * const nick, gboolean config_required,
|
void handle_muc_self_online(const char * const room, const char * const nick, gboolean config_required,
|
||||||
const char * const role, const char * const affiliation, const char * const jid, const char * const show,
|
const char * const role, const char * const affiliation, const char * const actor, const char * const reason,
|
||||||
const char * const status);
|
const char * const jid, const char * const show, const char * const status);
|
||||||
void handle_muc_occupant_online(const char * const room, const char * const nick, const char * const jid,
|
void handle_muc_occupant_online(const char * const room, const char * const nick, const char * const jid,
|
||||||
const char * const role, const char * const affiliation, const char * const show_str,
|
const char * const role, const char * const affiliation, const char * const show_str,
|
||||||
const char * const status_str);
|
const char * const status_str);
|
||||||
|
@ -1338,24 +1338,48 @@ _ui_switch_to_room(const char * const room)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_room_role_change(const char * const room, const char * const role)
|
_ui_room_role_change(const char * const room, const char * const role, const char * const actor,
|
||||||
|
const char * const reason)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_by_recipient(room);
|
ProfWin *window = wins_get_by_recipient(room);
|
||||||
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your role has been changed to: %s", role);
|
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your role has been changed to: %s", role);
|
||||||
|
if (actor) {
|
||||||
|
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor);
|
||||||
|
}
|
||||||
|
if (reason) {
|
||||||
|
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason);
|
||||||
|
}
|
||||||
|
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_room_affiliation_change(const char * const room, const char * const affiliation)
|
_ui_room_affiliation_change(const char * const room, const char * const affiliation, const char * const actor,
|
||||||
|
const char * const reason)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_by_recipient(room);
|
ProfWin *window = wins_get_by_recipient(room);
|
||||||
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation);
|
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation);
|
||||||
|
if (actor) {
|
||||||
|
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor);
|
||||||
|
}
|
||||||
|
if (reason) {
|
||||||
|
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason);
|
||||||
|
}
|
||||||
|
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_room_role_and_affiliation_change(const char * const room, const char * const role, const char * const affiliation)
|
_ui_room_role_and_affiliation_change(const char * const room, const char * const role, const char * const affiliation,
|
||||||
|
const char * const actor, const char * const reason)
|
||||||
{
|
{
|
||||||
ProfWin *window = wins_get_by_recipient(room);
|
ProfWin *window = wins_get_by_recipient(room);
|
||||||
win_save_vprint(window, '!', NULL, 0, COLOUR_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation);
|
win_save_vprint(window, '!', NULL, NO_EOL, COLOUR_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation);
|
||||||
|
if (actor) {
|
||||||
|
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", by: %s", actor);
|
||||||
|
}
|
||||||
|
if (reason) {
|
||||||
|
win_save_vprint(window, '!', NULL, NO_DATE | NO_EOL, COLOUR_ROOMINFO, "", ", reason: %s", reason);
|
||||||
|
}
|
||||||
|
win_save_print(window, '!', NULL, NO_DATE, COLOUR_ROOMINFO, "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -131,10 +131,12 @@ void (*ui_outgoing_msg)(const char * const from, const char * const to,
|
|||||||
const char * const message);
|
const char * const message);
|
||||||
void (*ui_room_join)(const char * const room, gboolean focus);
|
void (*ui_room_join)(const char * const room, gboolean focus);
|
||||||
void (*ui_switch_to_room)(const char * const room);
|
void (*ui_switch_to_room)(const char * const room);
|
||||||
void (*ui_room_role_change)(const char * const room, const char * const role);
|
void (*ui_room_role_change)(const char * const room, const char * const role, const char * const actor,
|
||||||
void (*ui_room_affiliation_change)(const char * const room, const char * const affiliation);
|
const char * const reason);
|
||||||
|
void (*ui_room_affiliation_change)(const char * const room, const char * const affiliation, const char * const actor,
|
||||||
|
const char * const reason);
|
||||||
void (*ui_room_role_and_affiliation_change)(const char * const room, const char * const role,
|
void (*ui_room_role_and_affiliation_change)(const char * const room, const char * const role,
|
||||||
const char * const affiliation);
|
const char * const affiliation, const char * const actor, const char * const reason);
|
||||||
void (*ui_room_roster)(const char * const room, GList *roster, const char * const presence);
|
void (*ui_room_roster)(const char * const room, GList *roster, const char * const presence);
|
||||||
void (*ui_room_history)(const char * const room_jid, const char * const nick,
|
void (*ui_room_history)(const char * const room_jid, const char * const nick,
|
||||||
GTimeVal tv_stamp, const char * const message);
|
GTimeVal tv_stamp, const char * const message);
|
||||||
|
@ -759,7 +759,9 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void *
|
|||||||
// self online
|
// self online
|
||||||
} else {
|
} else {
|
||||||
gboolean config_required = stanza_muc_requires_config(stanza);
|
gboolean config_required = stanza_muc_requires_config(stanza);
|
||||||
handle_muc_self_online(room, nick, config_required, role, affiliation, jid, show_str, status_str);
|
char *actor = stanza_get_kickban_actor(stanza);
|
||||||
|
char *reason = stanza_get_kickban_reason(stanza);
|
||||||
|
handle_muc_self_online(room, nick, config_required, role, affiliation, actor, reason, jid, show_str, status_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle presence from room members
|
// handle presence from room members
|
||||||
|
Loading…
Reference in New Issue
Block a user