Skip to content

Commit

Permalink
Simplify meeting OGP tags and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vcfxb committed Dec 31, 2021
1 parent db1ceb8 commit bb406e3
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/web/services/meetings/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use crate::api::rcos::meetings::authorization_for::{AuthorizationFor, UserMeetingAuthorization};
use crate::api::rcos::meetings::get_by_id::{meeting::MeetingMeeting, Meeting};
use crate::env::global_config;
use crate::error::TelescopeError;
use crate::templates::page::Page;
use crate::templates::tags::Tags;
Expand Down Expand Up @@ -66,17 +65,11 @@ pub async fn meeting(

// Create dynamic OGP tags and start with default so all other fields are correct
let mut tags = Tags::default();
tags.title = if meeting.title.is_some() {
format!("RCOS {} - {}", meeting.type_, meeting.title())
} else {
meeting.title()
};
tags.url = format!(
"{}/meeting/{}",
global_config().telescope_url,
meeting_id
);
// Set title and URL trivially.
tags.title = meeting.title();
tags.url = req.uri().to_string();

// Build description.
let mut description = String::new();
let start = Local.from_utc_datetime(&meeting.start_date_time.naive_utc());
let end = Local.from_utc_datetime(&meeting.end_date_time.naive_utc());
Expand All @@ -102,6 +95,8 @@ pub async fn meeting(
.as_str(),
);
}

// Add location if available.
if meeting.location.is_some() {
let location = meeting.location.as_ref().unwrap();
if location != "" {
Expand All @@ -110,15 +105,20 @@ pub async fn meeting(
} else if meeting.is_remote {
description.push_str(" @ Remote");
}

// Add a newline for formatting.
description.push_str("\n");

// Add the host if possible.
if meeting.host.is_some() {
let host = meeting.host.as_ref().unwrap();
description
.push_str(format!("Hosted By: {} {}\n", host.first_name, host.last_name).as_str());
}
if meeting.description != "" {
description.push_str(meeting.description.as_str());
}

// Add meeting description.
description.push_str(meeting.description.as_str());
// Add description to OGP tags.
tags.description = description;

// Build meeting template.
Expand Down

0 comments on commit bb406e3

Please sign in to comment.