0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 15:04:10 +01:00

modules/client: Upgrade event::append::opts et al to designated init menus.

This commit is contained in:
Jason Volk 2022-07-01 22:18:58 -07:00
parent 091a6fed60
commit c39876990d
10 changed files with 142 additions and 89 deletions

View file

@ -369,13 +369,14 @@ append_event(json::stack::array &out,
const int64_t &room_depth,
const m::user::room &user_room)
{
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.room_depth = &room_depth;
opts.user_room = &user_room;
opts.user_id = &user_room.user.user_id;
return m::event::append
{
out, event, opts
out, event,
{
.event_idx = &event_idx,
.user_id = &user_room.user.user_id,
.user_room = &user_room,
.room_depth = &room_depth,
},
};
}

View file

@ -84,12 +84,12 @@ ircd::m::get_notifications(client &client,
request.query.get<ushort>("limit", size_t(notifications_limit_default))
};
m::user::notifications::opts opts;
opts.only = only;
opts.to = 0UL;
opts.from = from?
lex_cast<event::idx>(from):
0UL;
const m::user::notifications::opts opts
{
.from = from? lex_cast<event::idx>(from): 0,
.to = 0,
.only = only,
};
const m::user::notifications notifications
{
@ -202,15 +202,16 @@ ircd::m::get_notifications(client &client,
object, "event"
};
m::event::append::opts opts;
opts.keys = &notification_event_keys;
opts.event_idx = &event_idx;
opts.query_redacted = false;
//opts.query_txnid = false;
//opts.query_prev_state = false;
m::event::append
{
event_object, event, opts
event_object, event,
{
.event_idx = &event_idx,
.keys = &notification_event_keys,
//.query_txnid = false,
//.query_prev_state = false,
.query_redacted = false,
},
};
++count;

View file

@ -136,12 +136,16 @@ get__context(client &client,
};
// We use m::event::append() to modify/add/remove data for this client.
m::event::append::opts opts;
opts.event_idx = &event.event_idx;
opts.user_id = &user_room.user.user_id;
opts.user_room = &user_room;
opts.room_depth = &room_depth;
m::event::append(_event, event, opts);
m::event::append
{
_event, event,
{
.event_idx = &event.event_idx,
.user_id = &user_room.user.user_id,
.user_room = &user_room,
.room_depth = &room_depth,
}
};
}
// Counters for debug messages
@ -302,10 +306,14 @@ _append(json::stack::array &chunk,
const int64_t &room_depth,
const bool &query_txnid)
{
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.user_id = &user_room.user.user_id;
opts.user_room = &user_room;
opts.room_depth = &room_depth;
return m::event::append(chunk, event, opts);
return m::event::append
{
chunk, event,
{
.event_idx = &event_idx,
.user_id = &user_room.user.user_id,
.user_room = &user_room,
.room_depth = &room_depth,
}
};
}

View file

@ -198,13 +198,18 @@ get__initialsync_local(client &client,
if(!visible(state_event, user.user_id))
return true;
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.user_id = &user.user_id;
opts.user_room = &user_room;
opts.room_depth = &room_depth;
opts.query_txnid = false;
m::event::append(state, state_event, opts);
m::event::append
{
state, state_event,
{
.event_idx = &event_idx,
.user_id = &user.user_id,
.user_room = &user_room,
.room_depth = &room_depth,
.query_txnid = false,
}
};
return true;
});
state.~array();
@ -247,13 +252,14 @@ get__initialsync_local(client &client,
if(!visible(event, user.user_id))
continue;
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.user_id = &user.user_id;
opts.user_room = &user_room;
opts.room_depth = &room_depth;
opts.query_txnid = true;
m::event::append(chunk, event, opts);
m::event::append(chunk, event,
{
.event_idx = &event_idx,
.user_id = &user.user_id,
.user_room = &user_room,
.room_depth = &room_depth,
.query_txnid = true,
});
}
}

View file

@ -221,12 +221,16 @@ _append(json::stack::array &chunk,
const m::user::room &user_room,
const int64_t &room_depth)
{
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.user_id = &user_room.user.user_id;
opts.user_room = &user_room;
opts.room_depth = &room_depth;
return m::event::append(chunk, event, opts);
return m::event::append
{
chunk, event,
{
.event_idx = &event_idx,
.user_id = &user_room.user.user_id,
.user_room = &user_room,
.room_depth = &room_depth,
}
};
}
// Client-Server 6.3.6 query parameters

View file

@ -117,13 +117,14 @@ try
const auto append{[&chunk, &request]
(const auto &event_idx, const m::event &event)
{
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.user_id = &request.user_id;
opts.query_txnid = false;
m::event::append
{
chunk, event, opts
chunk, event,
{
.event_idx = &event_idx,
.user_id = &request.user_id,
.query_txnid = false,
}
};
}};

View file

@ -189,15 +189,16 @@ append_event(const m::resource::request &request,
if(!visible(event, request.user_id))
return false;
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.user_id = &request.user_id;
opts.query_redacted = false;
opts.query_prev_state = false;
opts.query_txnid = false;
m::event::append
{
array, event, opts
array, event,
{
.event_idx = &event_idx,
.user_id = &request.user_id,
.query_txnid = false,
.query_prev_state = false,
.query_redacted = false,
},
};
return true;

View file

@ -430,12 +430,6 @@ try
object, "rank", json::value(result.rank)
};
m::event::append::opts opts;
opts.event_idx = &result.event_idx;
opts.user_id = &query.user_id;
opts.event_filter = &event_filter;
opts.query_prev_state = false;
opts.query_visible = true;
bool ret{false};
{
json::stack::object result_event
@ -443,7 +437,18 @@ try
object, "result"
};
ret = event::append(result_event, event, opts);
ret = event::append
{
result_event, event,
{
.event_idx = &result.event_idx,
.user_id = &query.user_id,
.event_filter = &event_filter,
.query_prev_state = false,
.query_visible = true,
},
};
result.appends += ret;
cp.committing(ret);
}
@ -481,8 +486,17 @@ try
it.event_idx()
};
opts.event_idx = &event_idx;
result.appends += event::append(events_before, event, opts);
result.appends += event::append
{
events_before, event,
{
.event_idx = &event_idx,
.user_id = &query.user_id,
.event_filter = &event_filter,
.query_prev_state = false,
.query_visible = true,
},
};
}
}
@ -501,8 +515,17 @@ try
it.event_idx()
};
opts.event_idx = &event_idx;
result.appends += event::append(events_after, event, opts);
result.appends += event::append
{
events_after, event,
{
.event_idx = &event_idx,
.user_id = &query.user_id,
.event_filter = &event_filter,
.query_prev_state = false,
.query_visible = true,
},
};
}
}

View file

@ -626,12 +626,16 @@ ircd::m::sync::room_state_append(data &data,
const m::event::idx &event_idx,
const bool &query_prev)
{
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.user_id = &data.user.user_id;
opts.user_room = &data.user_room;
opts.query_txnid = false;
opts.room_depth = &data.room_depth;
opts.query_prev_state = query_prev;
return m::event::append(events, event, opts);
return m::event::append
{
events, event,
{
.event_idx = &event_idx,
.user_id = &data.user.user_id,
.user_room = &data.user_room,
.room_depth = &data.room_depth,
.query_txnid = false,
.query_prev_state = query_prev,
}
};
}

View file

@ -368,11 +368,15 @@ ircd::m::sync::_room_timeline_append(data &data,
const m::event::idx &event_idx,
const m::event &event)
{
m::event::append::opts opts;
opts.event_idx = &event_idx;
opts.client_txnid = &data.client_txnid;
opts.user_id = &data.user.user_id;
opts.user_room = &data.user_room;
opts.room_depth = &data.room_depth;
return m::event::append(events, event, opts);
return m::event::append
{
events, event,
{
.event_idx = &event_idx,
.client_txnid = &data.client_txnid,
.user_id = &data.user.user_id,
.user_room = &data.user_room,
.room_depth = &data.room_depth,
}
};
}