mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
modules/client: Upgrade event::append::opts et al to designated init menus.
This commit is contained in:
parent
091a6fed60
commit
c39876990d
10 changed files with 142 additions and 89 deletions
|
@ -369,13 +369,14 @@ append_event(json::stack::array &out,
|
||||||
const int64_t &room_depth,
|
const int64_t &room_depth,
|
||||||
const m::user::room &user_room)
|
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
|
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,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,12 +84,12 @@ ircd::m::get_notifications(client &client,
|
||||||
request.query.get<ushort>("limit", size_t(notifications_limit_default))
|
request.query.get<ushort>("limit", size_t(notifications_limit_default))
|
||||||
};
|
};
|
||||||
|
|
||||||
m::user::notifications::opts opts;
|
const m::user::notifications::opts opts
|
||||||
opts.only = only;
|
{
|
||||||
opts.to = 0UL;
|
.from = from? lex_cast<event::idx>(from): 0,
|
||||||
opts.from = from?
|
.to = 0,
|
||||||
lex_cast<event::idx>(from):
|
.only = only,
|
||||||
0UL;
|
};
|
||||||
|
|
||||||
const m::user::notifications notifications
|
const m::user::notifications notifications
|
||||||
{
|
{
|
||||||
|
@ -202,15 +202,16 @@ ircd::m::get_notifications(client &client,
|
||||||
object, "event"
|
object, "event"
|
||||||
};
|
};
|
||||||
|
|
||||||
m::event::append::opts opts;
|
|
||||||
opts.keys = ¬ification_event_keys;
|
|
||||||
opts.event_idx = &event_idx;
|
|
||||||
opts.query_redacted = false;
|
|
||||||
//opts.query_txnid = false;
|
|
||||||
//opts.query_prev_state = false;
|
|
||||||
m::event::append
|
m::event::append
|
||||||
{
|
{
|
||||||
event_object, event, opts
|
event_object, event,
|
||||||
|
{
|
||||||
|
.event_idx = &event_idx,
|
||||||
|
.keys = ¬ification_event_keys,
|
||||||
|
//.query_txnid = false,
|
||||||
|
//.query_prev_state = false,
|
||||||
|
.query_redacted = false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
|
|
|
@ -136,12 +136,16 @@ get__context(client &client,
|
||||||
};
|
};
|
||||||
|
|
||||||
// We use m::event::append() to modify/add/remove data for this client.
|
// We use m::event::append() to modify/add/remove data for this client.
|
||||||
m::event::append::opts opts;
|
m::event::append
|
||||||
opts.event_idx = &event.event_idx;
|
{
|
||||||
opts.user_id = &user_room.user.user_id;
|
_event, event,
|
||||||
opts.user_room = &user_room;
|
{
|
||||||
opts.room_depth = &room_depth;
|
.event_idx = &event.event_idx,
|
||||||
m::event::append(_event, event, opts);
|
.user_id = &user_room.user.user_id,
|
||||||
|
.user_room = &user_room,
|
||||||
|
.room_depth = &room_depth,
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Counters for debug messages
|
// Counters for debug messages
|
||||||
|
@ -302,10 +306,14 @@ _append(json::stack::array &chunk,
|
||||||
const int64_t &room_depth,
|
const int64_t &room_depth,
|
||||||
const bool &query_txnid)
|
const bool &query_txnid)
|
||||||
{
|
{
|
||||||
m::event::append::opts opts;
|
return m::event::append
|
||||||
opts.event_idx = &event_idx;
|
{
|
||||||
opts.user_id = &user_room.user.user_id;
|
chunk, event,
|
||||||
opts.user_room = &user_room;
|
{
|
||||||
opts.room_depth = &room_depth;
|
.event_idx = &event_idx,
|
||||||
return m::event::append(chunk, event, opts);
|
.user_id = &user_room.user.user_id,
|
||||||
|
.user_room = &user_room,
|
||||||
|
.room_depth = &room_depth,
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,13 +198,18 @@ get__initialsync_local(client &client,
|
||||||
if(!visible(state_event, user.user_id))
|
if(!visible(state_event, user.user_id))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
m::event::append::opts opts;
|
m::event::append
|
||||||
opts.event_idx = &event_idx;
|
{
|
||||||
opts.user_id = &user.user_id;
|
state, state_event,
|
||||||
opts.user_room = &user_room;
|
{
|
||||||
opts.room_depth = &room_depth;
|
.event_idx = &event_idx,
|
||||||
opts.query_txnid = false;
|
.user_id = &user.user_id,
|
||||||
m::event::append(state, state_event, opts);
|
.user_room = &user_room,
|
||||||
|
.room_depth = &room_depth,
|
||||||
|
.query_txnid = false,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
state.~array();
|
state.~array();
|
||||||
|
@ -247,13 +252,14 @@ get__initialsync_local(client &client,
|
||||||
if(!visible(event, user.user_id))
|
if(!visible(event, user.user_id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m::event::append::opts opts;
|
m::event::append(chunk, event,
|
||||||
opts.event_idx = &event_idx;
|
{
|
||||||
opts.user_id = &user.user_id;
|
.event_idx = &event_idx,
|
||||||
opts.user_room = &user_room;
|
.user_id = &user.user_id,
|
||||||
opts.room_depth = &room_depth;
|
.user_room = &user_room,
|
||||||
opts.query_txnid = true;
|
.room_depth = &room_depth,
|
||||||
m::event::append(chunk, event, opts);
|
.query_txnid = true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,12 +221,16 @@ _append(json::stack::array &chunk,
|
||||||
const m::user::room &user_room,
|
const m::user::room &user_room,
|
||||||
const int64_t &room_depth)
|
const int64_t &room_depth)
|
||||||
{
|
{
|
||||||
m::event::append::opts opts;
|
return m::event::append
|
||||||
opts.event_idx = &event_idx;
|
{
|
||||||
opts.user_id = &user_room.user.user_id;
|
chunk, event,
|
||||||
opts.user_room = &user_room;
|
{
|
||||||
opts.room_depth = &room_depth;
|
.event_idx = &event_idx,
|
||||||
return m::event::append(chunk, event, opts);
|
.user_id = &user_room.user.user_id,
|
||||||
|
.user_room = &user_room,
|
||||||
|
.room_depth = &room_depth,
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client-Server 6.3.6 query parameters
|
// Client-Server 6.3.6 query parameters
|
||||||
|
|
|
@ -117,13 +117,14 @@ try
|
||||||
const auto append{[&chunk, &request]
|
const auto append{[&chunk, &request]
|
||||||
(const auto &event_idx, const m::event &event)
|
(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
|
m::event::append
|
||||||
{
|
{
|
||||||
chunk, event, opts
|
chunk, event,
|
||||||
|
{
|
||||||
|
.event_idx = &event_idx,
|
||||||
|
.user_id = &request.user_id,
|
||||||
|
.query_txnid = false,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|
|
@ -189,15 +189,16 @@ append_event(const m::resource::request &request,
|
||||||
if(!visible(event, request.user_id))
|
if(!visible(event, request.user_id))
|
||||||
return false;
|
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
|
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;
|
return true;
|
||||||
|
|
|
@ -430,12 +430,6 @@ try
|
||||||
object, "rank", json::value(result.rank)
|
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};
|
bool ret{false};
|
||||||
{
|
{
|
||||||
json::stack::object result_event
|
json::stack::object result_event
|
||||||
|
@ -443,7 +437,18 @@ try
|
||||||
object, "result"
|
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;
|
result.appends += ret;
|
||||||
cp.committing(ret);
|
cp.committing(ret);
|
||||||
}
|
}
|
||||||
|
@ -481,8 +486,17 @@ try
|
||||||
it.event_idx()
|
it.event_idx()
|
||||||
};
|
};
|
||||||
|
|
||||||
opts.event_idx = &event_idx;
|
result.appends += event::append
|
||||||
result.appends += event::append(events_before, event, opts);
|
{
|
||||||
|
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()
|
it.event_idx()
|
||||||
};
|
};
|
||||||
|
|
||||||
opts.event_idx = &event_idx;
|
result.appends += event::append
|
||||||
result.appends += event::append(events_after, event, opts);
|
{
|
||||||
|
events_after, event,
|
||||||
|
{
|
||||||
|
.event_idx = &event_idx,
|
||||||
|
.user_id = &query.user_id,
|
||||||
|
.event_filter = &event_filter,
|
||||||
|
.query_prev_state = false,
|
||||||
|
.query_visible = true,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -626,12 +626,16 @@ ircd::m::sync::room_state_append(data &data,
|
||||||
const m::event::idx &event_idx,
|
const m::event::idx &event_idx,
|
||||||
const bool &query_prev)
|
const bool &query_prev)
|
||||||
{
|
{
|
||||||
m::event::append::opts opts;
|
return m::event::append
|
||||||
opts.event_idx = &event_idx;
|
{
|
||||||
opts.user_id = &data.user.user_id;
|
events, event,
|
||||||
opts.user_room = &data.user_room;
|
{
|
||||||
opts.query_txnid = false;
|
.event_idx = &event_idx,
|
||||||
opts.room_depth = &data.room_depth;
|
.user_id = &data.user.user_id,
|
||||||
opts.query_prev_state = query_prev;
|
.user_room = &data.user_room,
|
||||||
return m::event::append(events, event, opts);
|
.room_depth = &data.room_depth,
|
||||||
|
.query_txnid = false,
|
||||||
|
.query_prev_state = query_prev,
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,11 +368,15 @@ ircd::m::sync::_room_timeline_append(data &data,
|
||||||
const m::event::idx &event_idx,
|
const m::event::idx &event_idx,
|
||||||
const m::event &event)
|
const m::event &event)
|
||||||
{
|
{
|
||||||
m::event::append::opts opts;
|
return m::event::append
|
||||||
opts.event_idx = &event_idx;
|
{
|
||||||
opts.client_txnid = &data.client_txnid;
|
events, event,
|
||||||
opts.user_id = &data.user.user_id;
|
{
|
||||||
opts.user_room = &data.user_room;
|
.event_idx = &event_idx,
|
||||||
opts.room_depth = &data.room_depth;
|
.client_txnid = &data.client_txnid,
|
||||||
return m::event::append(events, event, opts);
|
.user_id = &data.user.user_id,
|
||||||
|
.user_room = &data.user_room,
|
||||||
|
.room_depth = &data.room_depth,
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue