mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
Update incompatible uses of event_id.
This commit is contained in:
parent
9d5edac0b9
commit
43d66420cd
14 changed files with 39 additions and 48 deletions
|
@ -163,7 +163,5 @@ inline ircd::m::event::operator
|
||||||
id()
|
id()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
return json::get<"event_id"_>(*this)?
|
return event_id;
|
||||||
id{json::get<"event_id"_>(*this)}:
|
|
||||||
id{};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1467,7 +1467,7 @@ ircd::m::vm::eval::find(const event::id &event_id)
|
||||||
{
|
{
|
||||||
if(e.event_)
|
if(e.event_)
|
||||||
{
|
{
|
||||||
if(json::get<"event_id"_>(*e.event_) == event_id)
|
if(e.event_->event_id == event_id)
|
||||||
ret = &e;
|
ret = &e;
|
||||||
}
|
}
|
||||||
else if(e.issue)
|
else if(e.issue)
|
||||||
|
@ -1568,7 +1568,7 @@ ircd::m::vm::eval::eval(const json::array &pdus,
|
||||||
// any way we can elide a lot of grief by checking this here first and
|
// any way we can elide a lot of grief by checking this here first and
|
||||||
// skipping the event. The query path will be adequately cached anyway.
|
// skipping the event. The query path will be adequately cached anyway.
|
||||||
if(~(opts.warnlog | opts.errorlog) & fault::EXISTS)
|
if(~(opts.warnlog | opts.errorlog) & fault::EXISTS)
|
||||||
if(m::exists(m::event::id(at<"event_id"_>(event))))
|
if(m::exists(event.event_id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
operator()(event);
|
operator()(event);
|
||||||
|
|
|
@ -148,8 +148,8 @@ ircd::m::pretty_oneline(std::ostream &s,
|
||||||
else
|
else
|
||||||
s << "* ";
|
s << "* ";
|
||||||
|
|
||||||
if(defined(json::get<"event_id"_>(event)))
|
if(event.event_id)
|
||||||
s << json::get<"event_id"_>(event) << " ";
|
s << event.event_id << " ";
|
||||||
else
|
else
|
||||||
s << "* ";
|
s << "* ";
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ ircd::m::pretty_msgline(std::ostream &s,
|
||||||
s << json::get<"depth"_>(event) << " :";
|
s << json::get<"depth"_>(event) << " :";
|
||||||
s << json::get<"type"_>(event) << " ";
|
s << json::get<"type"_>(event) << " ";
|
||||||
s << json::get<"sender"_>(event) << " ";
|
s << json::get<"sender"_>(event) << " ";
|
||||||
s << json::get<"event_id"_>(event) << " ";
|
s << event.event_id << " ";
|
||||||
|
|
||||||
const auto &state_key
|
const auto &state_key
|
||||||
{
|
{
|
||||||
|
@ -394,7 +394,7 @@ ircd::m::append(json::stack::object &object,
|
||||||
const auto txnid_idx
|
const auto txnid_idx
|
||||||
{
|
{
|
||||||
!has_client_txnid && sender_is_user && opts.query_txnid?
|
!has_client_txnid && sender_is_user && opts.query_txnid?
|
||||||
opts.user_room->get(std::nothrow, "ircd.client.txnid", at<"event_id"_>(event)):
|
opts.user_room->get(std::nothrow, "ircd.client.txnid", event.event_id):
|
||||||
0UL
|
0UL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ ircd::m::append(json::stack::object &object,
|
||||||
log::dwarning
|
log::dwarning
|
||||||
{
|
{
|
||||||
log, "Could not find transaction_id for %s from %s in %s",
|
log, "Could not find transaction_id for %s from %s in %s",
|
||||||
json::get<"event_id"_>(event),
|
string_view{event.event_id},
|
||||||
json::get<"sender"_>(event),
|
json::get<"sender"_>(event),
|
||||||
json::get<"room_id"_>(event)
|
json::get<"room_id"_>(event)
|
||||||
};
|
};
|
||||||
|
@ -417,7 +417,7 @@ ircd::m::append(json::stack::object &object,
|
||||||
log::debug
|
log::debug
|
||||||
{
|
{
|
||||||
log, "Not sending event '%s' because '%s' is ignored by '%s'",
|
log, "Not sending event '%s' because '%s' is ignored by '%s'",
|
||||||
json::get<"event_id"_>(event),
|
string_view{event.event_id},
|
||||||
json::get<"sender"_>(event),
|
json::get<"sender"_>(event),
|
||||||
string_view{*opts.user_id}
|
string_view{*opts.user_id}
|
||||||
};
|
};
|
||||||
|
@ -717,7 +717,7 @@ ircd::m::event::conforms::conforms(const event &e)
|
||||||
set(INVALID_OR_MISSING_REDACTS_ID);
|
set(INVALID_OR_MISSING_REDACTS_ID);
|
||||||
|
|
||||||
if(json::get<"redacts"_>(e))
|
if(json::get<"redacts"_>(e))
|
||||||
if(json::get<"redacts"_>(e) == json::get<"event_id"_>(e))
|
if(json::get<"redacts"_>(e) == e.event_id)
|
||||||
set(SELF_REDACTS);
|
set(SELF_REDACTS);
|
||||||
|
|
||||||
if(json::get<"type"_>(e) == "m.room.member")
|
if(json::get<"type"_>(e) == "m.room.member")
|
||||||
|
@ -1663,7 +1663,7 @@ ircd::m::event::idx
|
||||||
ircd::m::index(const event &event)
|
ircd::m::index(const event &event)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return index(at<"event_id"_>(event));
|
return index(event.event_id);
|
||||||
}
|
}
|
||||||
catch(const json::not_found &)
|
catch(const json::not_found &)
|
||||||
{
|
{
|
||||||
|
@ -1678,7 +1678,7 @@ ircd::m::index(const event &event,
|
||||||
std::nothrow_t)
|
std::nothrow_t)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return index(at<"event_id"_>(event), std::nothrow);
|
return index(event.event_id, std::nothrow);
|
||||||
}
|
}
|
||||||
catch(const json::not_found &)
|
catch(const json::not_found &)
|
||||||
{
|
{
|
||||||
|
@ -1764,7 +1764,7 @@ ircd::m::event::auth::check(const event &event)
|
||||||
throw m::ACCESS_DENIED
|
throw m::ACCESS_DENIED
|
||||||
{
|
{
|
||||||
"Authorization of %s failed against its auth_events :%s",
|
"Authorization of %s failed against its auth_events :%s",
|
||||||
json::get<"event_id"_>(event),
|
string_view{event.event_id},
|
||||||
reason
|
reason
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2321,7 +2321,7 @@ ircd::m::event::auth::failed(const m::event &event,
|
||||||
|
|
||||||
// b. If the domain of the event_id of the event being redacted is the
|
// b. If the domain of the event_id of the event being redacted is the
|
||||||
// same as the domain of the event_id of the m.room.redaction, allow.
|
// same as the domain of the event_id of the m.room.redaction, allow.
|
||||||
if(event::id(json::get<"redacts"_>(event)).host() == event::id(at<"event_id"_>(event)).host())
|
if(event::id(json::get<"redacts"_>(event)).host() == user::id(at<"sender"_>(event)).host())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
// c. Otherwise, reject.
|
// c. Otherwise, reject.
|
||||||
|
@ -3414,7 +3414,7 @@ catch(const m::NOT_FOUND &e)
|
||||||
log::derror
|
log::derror
|
||||||
{
|
{
|
||||||
"Failed to verify %s because key %s for %s :%s",
|
"Failed to verify %s because key %s for %s :%s",
|
||||||
string_view{json::get<"event_id"_>(event)},
|
string_view{event.event_id},
|
||||||
keyid,
|
keyid,
|
||||||
origin,
|
origin,
|
||||||
e.what()
|
e.what()
|
||||||
|
@ -3768,7 +3768,7 @@ ircd::m::before(const event &a,
|
||||||
const event &b)
|
const event &b)
|
||||||
{
|
{
|
||||||
const event::prev prev{b};
|
const event::prev prev{b};
|
||||||
return prev.prev_events_has(at<"event_id"_>(a));
|
return prev.prev_events_has(a.event_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -3803,7 +3803,7 @@ bool
|
||||||
ircd::m::operator==(const event &a, const event &b)
|
ircd::m::operator==(const event &a, const event &b)
|
||||||
{
|
{
|
||||||
//assert(json::get<"room_id"_>(a) == json::get<"room_id"_>(b));
|
//assert(json::get<"room_id"_>(a) == json::get<"room_id"_>(b));
|
||||||
return json::get<"event_id"_>(a) == json::get<"event_id"_>(b);
|
return a.event_id == b.event_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -3896,7 +3896,7 @@ bool
|
||||||
ircd::m::my(const event &event)
|
ircd::m::my(const event &event)
|
||||||
{
|
{
|
||||||
const auto &origin(json::get<"origin"_>(event));
|
const auto &origin(json::get<"origin"_>(event));
|
||||||
const auto &eid(json::get<"event_id"_>(event));
|
const auto &eid(event.event_id);
|
||||||
return
|
return
|
||||||
origin?
|
origin?
|
||||||
my_host(origin):
|
my_host(origin):
|
||||||
|
|
|
@ -107,14 +107,14 @@ ircd::m::room::state::force_present(const m::event &event)
|
||||||
throw error
|
throw error
|
||||||
{
|
{
|
||||||
"event %s is not a room event (no room_id)",
|
"event %s is not a room event (no room_id)",
|
||||||
json::get<"event_id"_>(event)
|
string_view{event.event_id}
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!defined(json::get<"state_key"_>(event)))
|
if(!defined(json::get<"state_key"_>(event)))
|
||||||
throw error
|
throw error
|
||||||
{
|
{
|
||||||
"event %s is not a state event (no state_key)",
|
"event %s is not a state event (no state_key)",
|
||||||
json::get<"event_id"_>(event)
|
string_view{event.event_id}
|
||||||
};
|
};
|
||||||
|
|
||||||
dbs::write_opts opts;
|
dbs::write_opts opts;
|
||||||
|
@ -3746,7 +3746,7 @@ ircd::m::room::head::make_refs(const head &head,
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(need_tophead)
|
if(need_tophead)
|
||||||
if(json::get<"event_id"_>(event) == std::get<0>(top_head))
|
if(event.event_id == std::get<0>(top_head))
|
||||||
need_tophead = false;
|
need_tophead = false;
|
||||||
|
|
||||||
depth = std::max(json::get<"depth"_>(event), depth);
|
depth = std::max(json::get<"depth"_>(event), depth);
|
||||||
|
@ -4854,7 +4854,7 @@ ircd::m::dagree_histogram(const m::room &room,
|
||||||
log::warning
|
log::warning
|
||||||
{
|
{
|
||||||
m::log, "Event '%s' had %zu prev events (ignored)",
|
m::log, "Event '%s' had %zu prev events (ignored)",
|
||||||
string_view(at<"event_id"_>(event))
|
string_view{event.event_id},
|
||||||
};
|
};
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -189,7 +189,7 @@ get__context(client &client,
|
||||||
for(size_t i(0); i < limit && before; --before, ++i)
|
for(size_t i(0); i < limit && before; --before, ++i)
|
||||||
{
|
{
|
||||||
const m::event &event{*before};
|
const m::event &event{*before};
|
||||||
start = at<"event_id"_>(event);
|
start = event.event_id;
|
||||||
if(!visible(event, request.user_id))
|
if(!visible(event, request.user_id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ get__context(client &client,
|
||||||
for(size_t i(0); i < limit && after; ++after, ++i)
|
for(size_t i(0); i < limit && after; ++after, ++i)
|
||||||
{
|
{
|
||||||
const m::event &event{*after};
|
const m::event &event{*after};
|
||||||
end = at<"event_id"_>(event);
|
end = event.event_id;
|
||||||
if(!visible(event, request.user_id))
|
if(!visible(event, request.user_id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ ircd::m::invite_foreign(const event &event)
|
||||||
{
|
{
|
||||||
const auto &event_id
|
const auto &event_id
|
||||||
{
|
{
|
||||||
at<"event_id"_>(event)
|
event.event_id
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto &room_id
|
const auto &room_id
|
||||||
|
|
|
@ -293,7 +293,7 @@ try
|
||||||
{
|
{
|
||||||
const m::event::id &event_id
|
const m::event::id &event_id
|
||||||
{
|
{
|
||||||
at<"event_id"_>(event)
|
event.event_id
|
||||||
};
|
};
|
||||||
|
|
||||||
const m::room::id &room_id
|
const m::room::id &room_id
|
||||||
|
@ -387,7 +387,7 @@ catch(const std::exception &e)
|
||||||
log::error
|
log::error
|
||||||
{
|
{
|
||||||
join_log, "join bootstrap for %s to %s :%s",
|
join_log, "join bootstrap for %s to %s :%s",
|
||||||
string_view{at<"event_id"_>(event)},
|
string_view{event.event_id},
|
||||||
string(host),
|
string(host),
|
||||||
e.what()
|
e.what()
|
||||||
};
|
};
|
||||||
|
|
|
@ -152,7 +152,7 @@ get__messages(client &client,
|
||||||
for(; it; page.dir == 'b'? --it : ++it)
|
for(; it; page.dir == 'b'? --it : ++it)
|
||||||
{
|
{
|
||||||
const m::event &event{*it};
|
const m::event &event{*it};
|
||||||
end = at<"event_id"_>(event);
|
end = event.event_id;
|
||||||
if(hit > page.limit || miss >= size_t(max_filter_miss))
|
if(hit > page.limit || miss >= size_t(max_filter_miss))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ save_transaction_id(const m::event &event,
|
||||||
|
|
||||||
const auto &state_key
|
const auto &state_key
|
||||||
{
|
{
|
||||||
at<"event_id"_>(event)
|
event.event_id
|
||||||
};
|
};
|
||||||
|
|
||||||
send(user_room, at<"sender"_>(event), type, state_key,
|
send(user_room, at<"sender"_>(event), type, state_key,
|
||||||
|
|
|
@ -8377,7 +8377,7 @@ console_cmd__room__members__read(opt &out, const string_view &line)
|
||||||
out << timestr(at<"origin_server_ts"_>(event) / 1000)
|
out << timestr(at<"origin_server_ts"_>(event) / 1000)
|
||||||
<< " " << at<"sender"_>(event)
|
<< " " << at<"sender"_>(event)
|
||||||
<< " " << at<"content"_>(event)
|
<< " " << at<"content"_>(event)
|
||||||
<< " " << at<"event_id"_>(event)
|
<< " " << event.event_id
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
@ -10046,7 +10046,7 @@ console_cmd__user__presence(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
out << timestr(at<"origin_server_ts"_>(event) / 1000)
|
out << timestr(at<"origin_server_ts"_>(event) / 1000)
|
||||||
<< " " << at<"content"_>(event)
|
<< " " << at<"content"_>(event)
|
||||||
<< " " << at<"event_id"_>(event)
|
<< " " << event.event_id
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
return --limit > 0;
|
return --limit > 0;
|
||||||
|
@ -10142,7 +10142,7 @@ console_cmd__user__read(opt &out, const string_view &line)
|
||||||
out << timestr(at<"origin_server_ts"_>(event) / 1000)
|
out << timestr(at<"origin_server_ts"_>(event) / 1000)
|
||||||
<< " " << at<"state_key"_>(event)
|
<< " " << at<"state_key"_>(event)
|
||||||
<< " " << at<"content"_>(event)
|
<< " " << at<"content"_>(event)
|
||||||
<< " " << at<"event_id"_>(event)
|
<< " " << event.event_id
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
@ -10456,7 +10456,7 @@ console_cmd__user__tokens(opt &out, const string_view &line)
|
||||||
{
|
{
|
||||||
const auto eid
|
const auto eid
|
||||||
{
|
{
|
||||||
m::redact(m::user::tokens, user.user_id, at<"event_id"_>(event), "cleared")
|
m::redact(m::user::tokens, user.user_id, event.event_id, "cleared")
|
||||||
};
|
};
|
||||||
|
|
||||||
out << " - cleared by " << eid;
|
out << " - cleared by " << eid;
|
||||||
|
|
|
@ -237,7 +237,7 @@ try
|
||||||
vmopts.fetch_prev_check = false;
|
vmopts.fetch_prev_check = false;
|
||||||
vmopts.fetch_prev = false;
|
vmopts.fetch_prev = false;
|
||||||
|
|
||||||
vmopts.non_conform |= m::event::conforms::INVALID_OR_MISSING_EVENT_ID;
|
// Don't throw an exception for a re-evaluation; this will just be a no-op
|
||||||
vmopts.nothrows |= m::vm::fault::EXISTS;
|
vmopts.nothrows |= m::vm::fault::EXISTS;
|
||||||
|
|
||||||
m::vm::eval
|
m::vm::eval
|
||||||
|
|
|
@ -437,7 +437,7 @@ try
|
||||||
|
|
||||||
const m::event::id &event_id
|
const m::event::id &event_id
|
||||||
{
|
{
|
||||||
at<"event_id"_>(event)
|
event.event_id
|
||||||
};
|
};
|
||||||
|
|
||||||
const time_t &ms
|
const time_t &ms
|
||||||
|
|
|
@ -22,7 +22,7 @@ _can_create_room(const m::event &event,
|
||||||
{
|
{
|
||||||
const m::event::id &event_id
|
const m::event::id &event_id
|
||||||
{
|
{
|
||||||
at<"event_id"_>(event)
|
event.event_id
|
||||||
};
|
};
|
||||||
|
|
||||||
const m::room::id &room_id
|
const m::room::id &room_id
|
||||||
|
@ -43,12 +43,12 @@ _can_create_room(const m::event &event,
|
||||||
sender.host()
|
sender.host()
|
||||||
};
|
};
|
||||||
|
|
||||||
if(room_id.host() != event_id.host())
|
if(room_id.host() != sender.host())
|
||||||
throw m::ACCESS_DENIED
|
throw m::ACCESS_DENIED
|
||||||
{
|
{
|
||||||
"Room on '%s' cannot be created by event from '%s'",
|
"Room on '%s' cannot be created by event from '%s'",
|
||||||
room_id.host(),
|
room_id.host(),
|
||||||
event_id.host()
|
sender.host()
|
||||||
};
|
};
|
||||||
|
|
||||||
if(room_id.host() != at<"origin"_>(event))
|
if(room_id.host() != at<"origin"_>(event))
|
||||||
|
@ -111,7 +111,7 @@ _created_room(const m::event &event,
|
||||||
m::log, "Creation of room %s by %s (%s)",
|
m::log, "Creation of room %s by %s (%s)",
|
||||||
string_view{room_id},
|
string_view{room_id},
|
||||||
at<"sender"_>(event),
|
at<"sender"_>(event),
|
||||||
at<"event_id"_>(event)
|
string_view{event.event_id},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -503,13 +503,6 @@ try
|
||||||
if(opts.conform)
|
if(opts.conform)
|
||||||
call_hook(conform_hook, eval, event, eval);
|
call_hook(conform_hook, eval, event, eval);
|
||||||
|
|
||||||
if(json::get<"event_id"_>(event))
|
|
||||||
if(event.event_id != json::get<"event_id"_>(event))
|
|
||||||
throw error
|
|
||||||
{
|
|
||||||
fault::INVALID, "event.event_id not set."
|
|
||||||
};
|
|
||||||
|
|
||||||
const fault ret
|
const fault ret
|
||||||
{
|
{
|
||||||
event.event_id?
|
event.event_id?
|
||||||
|
|
Loading…
Reference in a new issue