File tree Expand file tree Collapse file tree 5 files changed +16
-2
lines changed
crates/crates_io_database/src
migrations/2025-02-11-122509_add-expires-at-column Expand file tree Collapse file tree 5 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,8 @@ diesel::table! {
221221 ///
222222 /// (Automatically generated by Diesel.)
223223 token -> Text ,
224+ /// Point in time at which the invitation expires/expired.
225+ expires_at -> Nullable <Timestamptz >,
224226 }
225227}
226228
Original file line number Diff line number Diff line change 1+ alter table crate_owner_invitations drop column expires_at;
Original file line number Diff line number Diff line change 1+ alter table crate_owner_invitations add column expires_at timestamptz ;
2+
3+ comment on column public.crate_owner_invitations.expires_at is ' Point in time at which the invitation expires/expired.'
4+
5+ -- to be performed manually after the migration:
6+ --
7+ -- update table crate_owner_invitations set expires_at = now() + interval '30 day';
Original file line number Diff line number Diff line change 1- use chrono:: { NaiveDateTime , Utc } ;
1+ use chrono:: { DateTime , NaiveDateTime , Utc } ;
22use diesel:: prelude:: * ;
33use diesel_async:: scoped_futures:: ScopedFutureExt ;
44use diesel_async:: { AsyncConnection , AsyncPgConnection , RunQueryDsl } ;
@@ -20,6 +20,7 @@ pub struct NewCrateOwnerInvitation {
2020 pub invited_user_id : i32 ,
2121 pub invited_by_user_id : i32 ,
2222 pub crate_id : i32 ,
23+ pub expires_at : DateTime < Utc > ,
2324}
2425
2526impl NewCrateOwnerInvitation {
@@ -82,6 +83,7 @@ pub struct CrateOwnerInvitation {
8283 pub created_at : NaiveDateTime ,
8384 #[ diesel( deserialize_as = String ) ]
8485 pub token : SecretString ,
86+ pub expires_at : Option < DateTime < Utc > > ,
8587}
8688
8789impl CrateOwnerInvitation {
Original file line number Diff line number Diff line change 1- use chrono:: NaiveDateTime ;
1+ use chrono:: { NaiveDateTime , Utc } ;
22use diesel:: associations:: Identifiable ;
33use diesel:: dsl;
44use diesel:: pg:: Pg ;
@@ -401,10 +401,12 @@ impl Crate {
401401 match owner {
402402 // Users are invited and must accept before being added
403403 Owner :: User ( user) => {
404+ let expires_at = Utc :: now ( ) + app. config . ownership_invitations_expiration ;
404405 let invite = NewCrateOwnerInvitation {
405406 invited_user_id : user. id ,
406407 invited_by_user_id : req_user. id ,
407408 crate_id : self . id ,
409+ expires_at,
408410 } ;
409411
410412 let creation_ret = invite
You can’t perform that action at this time.
0 commit comments