App needs to let users send an invitation email to other potential
users. The invitations contain a special link that gets you access to
the registration pg. When you submit an email adr to invite, the
handler method needs to save a record in the Invitations table, and
actually send the email. Both those actions seem to me like they
belong at the model-level, since they're so tightly related -- the db
record is what makes the email invite valid.
So, I thought RegisterService.createInvitation should do both. The
contents of the email are completely static except for the actual link
and the name of the person who sent it, so I built a getEmailBody
method in RegisterService.
However, buildLink, which is how the link in the email should be
built, isn't available to services. I wondered if that meant I was
thinking about this wrong, that the email was really a view, where
buildLink would be available. Still, I can't get past how coupled the
email and the db record are. It shouldn't be the handler that gets a
random key and coordinates the email/db thing, it's all one
model-level action. The content of the email seems like a business
rule, and the view layer is different, it's what the user sees after
they submit.
So how can I access buildLink from a service? What other strategies
should I think about to get past this?
Dave