From 47e47236abde15847a7fc983fae46b189dbd2176 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Thu, 30 Nov 2023 18:29:10 +0100 Subject: [PATCH] Add GUID to items --- Jenkinsfile | 1 + src/main.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 22e0298..6a7295b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,6 +36,7 @@ pipeline { } } } + // For this to work, edit sonar-scanner script to set use_embedded_jre=false stage('SonarQube Analysis') { steps { withSonarQubeEnv(installationName: 'SQ Bib Watcher', envOnly: true) { diff --git a/src/main.rs b/src/main.rs index 501bf93..8a2bf61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use config::Config; use reqwest::header; -use rss::{Channel, ChannelBuilder, ItemBuilder}; +use rss::{Channel, ChannelBuilder, GuidBuilder, ItemBuilder}; use scraper::{Html, Selector}; use std::collections::HashMap; use std::{error::Error, fs::File, io::BufReader}; @@ -84,12 +84,17 @@ fn search(url: &str, title: &str) -> Result<(), Box> { .build()), }?; let mut items = channel.clone().into_items(); + let guid = GuidBuilder::default() + .value(title.to_string() + &Utc::now().to_rfc2822()) + .permalink(false) + .build(); items.push( ItemBuilder::default() .title(Some(title.to_string())) .pub_date(Some(Utc::now().to_rfc2822())) .link(Some(url.to_string())) .description(Some(status)) + .guid(Some(guid)) .build(), ); channel.set_items(items);