Skip to content

Commit

Permalink
Fix repost test: don't add to db if pre-post found, but later negated
Browse files Browse the repository at this point in the history
Even if a pre-post is found, various configurations can cause the result
of this look up to be ignored, meaning another pre-post entry will be
added to the database.

Add a flag to preserve this state, even if the actual result of the
pre-post look up is masked by configuration.

Also fix 0.0.0.0 to 127.0.0.1 after rebase.
  • Loading branch information
nuxeh committed Feb 7, 2020
1 parent 4adb250 commit a79bf2d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ fn process_titles(rtd: &Rtd, db: &Database, msg: &Msg) -> impl Iterator<Item = T
Ok(None)
};

let pre_post_found = if let Ok(Some(_)) = pre_post {
true
} else {
false
};

// limit pre-post to same channel if required by configuration
let pre_post = if rtd.conf.features.cross_channel_history {
pre_post
Expand Down Expand Up @@ -225,7 +231,7 @@ fn process_titles(rtd: &Rtd, db: &Database, msg: &Msg) -> impl Iterator<Item = T
},
Ok(None) => {
// add new log entry to database, if posted in a channel
if rtd.conf.features.history && msg.is_chanmsg {
if rtd.conf.features.history && !pre_post_found && msg.is_chanmsg {
if let Err(err) = db.add_log(&entry) {
error!("SQL error: {}", err);
}
Expand Down Expand Up @@ -530,7 +536,7 @@ mod tests {

rtd.conf.features.mask_highlights = false;

let msg2 = Msg::new(&rtd, "testnick", "#test2", "http://0.0.0.0:8084/");
let msg2 = Msg::new(&rtd, "testnick", "#test2", "http://127.0.0.1:8084/");

// cross-posted history is disabled
let res: Vec<_> = process_titles(&rtd, &db, &msg2).collect();
Expand Down

0 comments on commit a79bf2d

Please sign in to comment.