-
Notifications
You must be signed in to change notification settings - Fork 9
send emails to users that are mentioned in bucket comments #195
base: master
Are you sure you want to change the base?
Conversation
@jlopker The email that's being sent look like this
So the HTML is being displayed, not actually interpreted as HTML. The source in the mail is this
|
@chime-mu oh that's very odd! is that how the emails are showing up in mailcatcher? for me, they're showing up normal... |
@jlopker That is indeed very odd. Could you take a look at the mail source? I'm wondering if this is connected to my message including 8-bit/non-ascii characters? |
@chime-mu i ended up getting that same problem when I pulled down the code again.. very strange. but i think i fixed it now. let me know if that's working for you. |
@jlopker Tested once more. The mail now looks good. However there's still a few things not working.
Protocol changesIn the version of cobudget in the master branch the API regarding comments (POST'ing as well as GET'ing) the body is always pure markdown. I think that's a great solution, because it makes the API useful for different kind of frontends. The version in this branch sends something in between. Several Also, when posting an @-mention, it's HTML |
I can't see the comments you wrote in the code... So I'm struggling a bit to figure out how to make this work. If when you @mentioned someone, the mention was converted to markdown, it would use the bracket/parentheses markdown link style. I had this at first, but everyone agreed it looked too nerdy. So I changed it to look like a normal link (with an tag) but this causes the mixing of the html and markdown. To combat this, I convert the html to markdown on the backend before it gets saved. Do you have another idea of how this could work? Other option I explored was to not do any styling of the @-mentions on the front end and have the backend search for @'s and convert them to links. but the problem with this is that we don't have usernames and often the names we're using have spaces. So it makes it really hard to figure out what the "right" name is and then search on it. What do you think? Is there another obvious solution that i'm missing? |
The architecture that makes sense to me is that the backend and frontend(s) has a fairly stable protocol. Two reasons:
Up to this point, the body part of the comments has been in pure markdown. This is not as well-specified as I prefer, since there exist different definitions of markdown, but it's good enough in my view. By mixing HTML and markdown in becomes quite unclear what the content of the body field can be - and this increases coupling between backend and frontend - and makes it harder for us and others to make a different frontend. So I agree the the @-mention should look like a link. That's what users expect. And the it should be converted to mark-down in the frontend. This is in general a good way to divide responsibility. The frontend decides how things should be entered, edited and displayed. That's a frontend responsibility. The backend receives, stores, manipulates, filters and finds well-defined data. Does this make sense? |
hmm I don't think I explained myself well enough.. the problem is with the display in the text box and with getting all the necessary information to the backend (we need the user id for everyone that was @-mentioned). I don't see a clear way to do this if we use markdown exclusively. if this doesn't make sense, let's hop on the phone to chat about it! |
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.
I'm thinking if the frontend can send <a href="http://localhost:9000/users/5093" name="5093">@Bum</a>
it could just as well send [@Bum](user://5093)
(or something similar).
That said there might very well be something I'm not seeing clearly, so let's hop on the phone and talk about it.
I'll send you a doodle with a few choices later today.
bucket = Bucket.find(comment_params[:bucket_id]) | ||
user_links.each do |userId| | ||
user = User.find(userId) | ||
UserMailer.notify_member_that_they_were_mentioned(author: current_user, member: user, bucket: bucket, body: email_body).deliver_now |
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.
We should use deliver_later
instead of deliver_now
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.
ah yes i did that for testing purposes and forgot to revert! change pushed!
That's what I was doing initially but the problem with that is that using that syntax would make |
@chime-mu this is ready for another review! i formatted the links as |
@chime-mu errr ok so this is weird.. when I test with |
@jlopker That sounds really weird. Happy to test and take a look first thing tomorrow :) |
@jlopker The link to the user in the mail doesn't work when I click in firefox. This is tested on localhost, so not sure if the same problem be there when fully deployed. However it's probably a good idea to make it work when testing on localhost as well. |
user = User.find(userId) | ||
UserMailer.notify_member_that_they_were_mentioned(author: current_user, member: user, bucket: bucket, body: email_body).deliver_later | ||
end | ||
end |
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.
I wouldn't put the code that converts from markdown to HTML in the controller, but rather in the user_mailer
code that generates the mail.
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.
@chime-mu It's not always the case that the user_mailer
would get called though. If no one is mentioned in the comment then no mails would get sent. Because of this, I'm not sure that it makes sense to me to put this code in the user_mailer
. Does that make sense? Or is there something I'm not seeing?
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.
Why would you convert to HTML if no mail should be sent?
@chime-mu What do you mean the link doesn't work? Like you click on it and then nothing happens? |
No description provided.