Merge pull request 'have unique uid's, fixes error in some clients (e.g. sogo)' (#896) from fix-cal-uid into main

Reviewed-on: Ruderverein-Donau-Linz/rowt#896
This commit is contained in:
philipp 2025-04-15 20:56:00 +02:00
commit dfb53291b7
2 changed files with 23 additions and 3 deletions

View File

@ -191,7 +191,8 @@ INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id",
let mut ret = Vec::new(); let mut ret = Vec::new();
let events = Self::all(db).await; let events = Self::all(db).await;
for event in events { for event in events {
if event.is_rower_registered(db, user).await { if event.is_rower_registered(db, user).await || event.is_cox_registered(db, user).await
{
ret.push(event); ret.push(event);
} }
} }
@ -215,6 +216,21 @@ INNER JOIN trip_details ON planned_event.trip_details_id = trip_details.id",
is_rower.amount > 0 is_rower.amount > 0
} }
pub async fn is_cox_registered(&self, db: &SqlitePool, user: &User) -> bool {
let is_rower = sqlx::query!(
"SELECT count(*) as amount
FROM trip
WHERE planned_event_id = ?
AND cox_id = ?",
self.id,
user.id
)
.fetch_one(db)
.await
.unwrap(); //Okay, bc planned_event can only be created with proper DB backing
is_rower.amount > 0
}
pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> { pub async fn find_by_trip_details(db: &SqlitePool, tripdetails_id: i64) -> Option<Self> {
sqlx::query_as!( sqlx::query_as!(
Self, Self,
@ -427,7 +443,10 @@ WHERE trip_details.id=?
} }
pub(crate) async fn get_vevent(self, db: &SqlitePool) -> ics::Event { pub(crate) async fn get_vevent(self, db: &SqlitePool) -> ics::Event {
let mut vevent = ics::Event::new(format!("{}@rudernlinz.at", self.id), "19900101T180000"); let mut vevent = ics::Event::new(
format!("event-{}@rudernlinz.at", self.id),
"19900101T180000",
);
vevent.push(DtStart::new(format!( vevent.push(DtStart::new(format!(
"{}T{}00", "{}T{}00",
self.day.replace('-', ""), self.day.replace('-', ""),

View File

@ -138,7 +138,8 @@ WHERE trip_details.id=?
} }
pub(crate) async fn get_vevent(self, user: &User) -> ics::Event { pub(crate) async fn get_vevent(self, user: &User) -> ics::Event {
let mut vevent = ics::Event::new(format!("{}@rudernlinz.at", self.id), "19900101T180000"); let mut vevent =
ics::Event::new(format!("trip-{}@rudernlinz.at", self.id), "19900101T180000");
vevent.push(DtStart::new(format!( vevent.push(DtStart::new(format!(
"{}T{}00", "{}T{}00",
self.day.replace('-', ""), self.day.replace('-', ""),