-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix follow IDs #455
Fix follow IDs #455
Conversation
@@ -227,7 +227,6 @@ pub fn update(blog: String, slug: String, user: User, cl: ContentLen, form: Leni | |||
post.license = form.license.clone(); | |||
post.cover_id = form.cover; | |||
post.update(&*conn, &searcher).expect("post::update: update error");; | |||
let post = post.update_ap_url(&*conn).expect("post::update: update ap url error"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: I removed that without replacing it with something else, since it is incorrect (the AP IDs should change), and was not working anyway (since we were checking if ap_url
was empty before updating it, which was only the case on newly created articles).
Codecov Report
@@ Coverage Diff @@
## master #455 +/- ##
==========================================
+ Coverage 25.06% 26.48% +1.41%
==========================================
Files 64 64
Lines 6316 7111 +795
==========================================
+ Hits 1583 1883 +300
- Misses 4733 5228 +495 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
insert!(follows, NewFollow); | ||
insert!(follows, NewFollow, |inserted, conn| { | ||
if inserted.ap_url.is_empty() { | ||
inserted.ap_url = ap_url(&format!("{}/follows/{}", *BASE_URL, inserted.id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this route should really get implemented one day
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we already have an issue for it…
I changed the syntax of the
insert!
macro, allowing to modify an object just after it was saved to the database. You can now optional pass it a "closure" (actually it just looks like a closure) that will be run just after the insertion.I updated all the models, including Follow, to use it to generate AP ID and URL. The advantages are that the ID/URL are now correct (fixes #449) and that we don't have methods like
update_boxes
orupdate_ap_url
to call manually and that were easy to forget.