File tree Expand file tree Collapse file tree 6 files changed +17
-2
lines changed
crates_io_database_dump/src
migrations/2025-02-11-122509_add-expires-at-column Expand file tree Collapse file tree 6 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,8 @@ diesel::table! {
221
221
///
222
222
/// (Automatically generated by Diesel.)
223
223
token -> Text ,
224
+ /// Point in time at which the invitation expires/expired.
225
+ expires_at -> Nullable <Timestamptz >,
224
226
}
225
227
}
226
228
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ invited_by_user_id = "private"
59
59
crate_id = " private"
60
60
created_at = " private"
61
61
token = " private"
62
+ expires_at = " private"
62
63
63
64
[crate_owners ]
64
65
dependencies = [" crates" , " users" ]
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 } ;
2
2
use diesel:: prelude:: * ;
3
3
use diesel_async:: scoped_futures:: ScopedFutureExt ;
4
4
use diesel_async:: { AsyncConnection , AsyncPgConnection , RunQueryDsl } ;
@@ -20,6 +20,7 @@ pub struct NewCrateOwnerInvitation {
20
20
pub invited_user_id : i32 ,
21
21
pub invited_by_user_id : i32 ,
22
22
pub crate_id : i32 ,
23
+ pub expires_at : DateTime < Utc > ,
23
24
}
24
25
25
26
impl NewCrateOwnerInvitation {
@@ -82,6 +83,7 @@ pub struct CrateOwnerInvitation {
82
83
pub created_at : NaiveDateTime ,
83
84
#[ diesel( deserialize_as = String ) ]
84
85
pub token : SecretString ,
86
+ pub expires_at : Option < DateTime < Utc > > ,
85
87
}
86
88
87
89
impl CrateOwnerInvitation {
Original file line number Diff line number Diff line change 1
- use chrono:: NaiveDateTime ;
1
+ use chrono:: { NaiveDateTime , Utc } ;
2
2
use diesel:: associations:: Identifiable ;
3
3
use diesel:: dsl;
4
4
use diesel:: pg:: Pg ;
@@ -400,10 +400,12 @@ impl Crate {
400
400
match owner {
401
401
// Users are invited and must accept before being added
402
402
Owner :: User ( user) => {
403
+ let expires_at = Utc :: now ( ) + app. config . ownership_invitations_expiration ;
403
404
let invite = NewCrateOwnerInvitation {
404
405
invited_user_id : user. id ,
405
406
invited_by_user_id : req_user. id ,
406
407
crate_id : self . id ,
408
+ expires_at,
407
409
} ;
408
410
409
411
let creation_ret = invite
You can’t perform that action at this time.
0 commit comments