Skip to content

Commit

Permalink
Per TODO, clear out user variables that become blank
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Jun 23, 2023
1 parent 8c65d45 commit 2a2406d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 5 additions & 0 deletions connection.pike
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ class channel(string name) { //name begins with hash and is all lower case
}
//Otherwise, keep the string exactly as-is.
vars[var] = val;
if (val == "" && per_user) {
//Per-user variables don't need to store blank
m_delete(vars, var);
if (!sizeof(vars)) m_delete(fetcher("variables", name, "*"), (string)users[?user]);
}
if (ephemeral) return val; //Ephemeral variables are not pushed out to listeners.
//Notify those that depend on this. Note that an unadorned per-user variable is
//probably going to behave bizarrely in a monitor, so don't do that; use either
Expand Down
2 changes: 0 additions & 2 deletions modules/http/chan_variables.pike
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ void websocket_cmd_update(mapping(string:mixed) conn, mapping(string:mixed) msg)
string var = "*" + replace(msg->id, "*|${}" / 1, "");
//TODO: Filter to existing variables according to the all_per_user set
//Currently just filters by validity.
//TODO: If value == "", delete this user's instance of the variable.
//And if that leaves the user's mapping empty, remove it altogether.
foreach (msg->per_user; string uid; string value)
channel->set_variable(var, value, "set", (["": uid]));
return;
Expand Down

0 comments on commit 2a2406d

Please sign in to comment.