Revert all of my sendwithus changes

Revert "Fix more sendwithus things"

This reverts commit 9d4215d99d.

Revert "Fix some missed sendwithus changes"

This reverts commit 08bc32e005.

Revert "Fix email tests"

This reverts commit fcb2ce8504.

Revert "Use SendWithUs versioning"

This reverts commit 81d9e19221.
This commit is contained in:
phoenixeliot 2016-06-06 16:53:05 -07:00
parent 9d4215d99d
commit c191f63c15
15 changed files with 43 additions and 62 deletions

View file

@ -91,8 +91,7 @@ emailUserInitialRecruiting = (user, callback) ->
team = user.session.levelInfo.team
team = team.substr(0, team.length - 1)
context =
email_id: sendwithus.templates.recruiting_email.id
version_name: sendwithus.templates.recruiting_email.version
email_id: sendwithus.templates.recruiting_email
recipient:
address: if DEBUGGING then 'nick@codecombat.com' else user.email
name: name
@ -135,8 +134,7 @@ emailUserTournamentResults = (winner, callback) ->
name = winner.name
team = winner.team.substr(0, winner.team.length - 1)
context =
email_id: sendwithus.templates.greed_tournament_rank.id
version_name: sendwithus.templates.greed_tournament_rank.version
email_id: sendwithus.templates.greed_tournament_rank
recipient:
address: if DEBUGGING then 'nick@codecombat.com' else winner.email
name: name

View file

@ -468,8 +468,7 @@ module.exports = class Handler
notifyWatcherOfChange: (editor, watcher, changedDocument, editPath) ->
context =
email_id: sendwithus.templates.change_made_notify_watcher.id
version_name: sendwithus.templates.change_made_notify_watcher.version
email_id: sendwithus.templates.change_made_notify_watcher
recipient:
address: watcher.get('email')
name: watcher.get('name')

View file

@ -187,8 +187,7 @@ CourseInstanceHandler = class CourseInstanceHandler extends Handler
return @sendForbiddenError(res) unless prepaid.get('maxRedeemers') > prepaid.get('redeemers').length
for email in req.body.emails
context =
email_id: sendwithus.templates.course_invite_email.id
version: sendwithus.templates.course_invite_email.version
email_id: sendwithus.templates.course_invite_email
recipient:
address: email
subject: course.get('name')

View file

@ -100,8 +100,7 @@ PatchHandler = class PatchHandler extends Handler
sendPatchCreatedEmail: (patchCreator, watcher, patch, target, docLink) ->
# return if watcher._id is patchCreator._id
context =
email_id: sendwithus.templates.patch_created.id
version_name: sendwithus.templates.patch_created.version
email_id: sendwithus.templates.patch_created
recipient:
address: watcher.get('email')
name: watcher.get('name')

View file

@ -457,11 +457,9 @@ UserHandler = class UserHandler extends Handler
# Type-specific email data
if type is 'subscribe modal parent'
emailParams['email_id'] = sendwithus.templates.parent_subscribe_email.id
emailParams['version_name'] = sendwithus.templates.parent_subscribe_email.version
emailParams['email_id'] = sendwithus.templates.parent_subscribe_email
else if type is 'share progress modal parent'
emailParams['email_id'] = sendwithus.templates.share_progress_email.id
emailParams['version_name'] = sendwithus.templates.share_progress_email.version
emailParams['email_id'] = sendwithus.templates.share_progress_email
sendMail emailParams

View file

@ -52,7 +52,7 @@ module.exports =
yield req.logInAsync(user)
if req.query.callback
res.jsonp(req.user.toObject({req, publicOnly: true}))
res.jsonp(req.user.toObject({req, publicOnly: true}))
else
res.send(req.user.toObject({req, publicOnly: false}))
res.end()
@ -132,8 +132,7 @@ module.exports =
user.set('passwordReset', utils.getCodeCamel())
yield user.save()
context =
email_id: sendwithus.templates.password_reset.id
version_name: sendwithus.templates.password_reset.version
email_id: sendwithus.templates.password_reset
recipient:
address: req.body.email
email_data:

View file

@ -235,8 +235,7 @@ module.exports =
for email in req.body.emails
joinCode = (classroom.get('codeCamel') or classroom.get('code'))
context =
email_id: sendwithus.templates.course_invite_email.id
version_name: sendwithus.templates.course_invite_email.version
email_id: sendwithus.templates.course_invite_email
recipient:
address: email
email_data:

View file

@ -85,8 +85,7 @@ module.exports =
if not user
throw new errors.NotFound('User not found')
context =
email_id: sendwithus.templates.verify_email.id
version_name: sendwithus.templates.verify_email.version
email_id: sendwithus.templates.verify_email
recipient:
address: user.get('email')
name: user.broadName()

View file

@ -107,8 +107,7 @@ module.exports =
User.find({_id:{$in:watchers}}).select({email:1, name:1}).exec (err, watchers) ->
for watcher in watchers
context =
email_id: sendwithus.templates.change_made_notify_watcher.id
version_name: sendwithus.templates.change_made_notify_watcher.version
email_id: sendwithus.templates.change_made_notify_watcher
recipient:
address: watcher.get('email')
name: watcher.get('name')
@ -128,7 +127,7 @@ module.exports =
original = req.params.handle
version = req.params.version
if not database.isID(original)
throw new errors.UnprocessableEntity('Invalid MongoDB id: '+original)
throw new errors.UnprocessableEntity('Invalid MongoDB id: '+original)
query = { 'original': mongoose.Types.ObjectId(original) }
if version?

View file

@ -272,8 +272,7 @@ UserSchema.methods.register = (done) ->
{ welcome_email_student, welcome_email_user } = sendwithus.templates
timestamp = (new Date).getTime()
data =
email_id: if @isStudent() then welcome_email_student.id else welcome_email_user.id
version_name: if @isStudent() then welcome_email_student.version else welcome_email_user.version
email_id: if @isStudent() then welcome_email_student else welcome_email_user
recipient:
address: @get('email')
name: @broadName()

View file

@ -17,7 +17,7 @@ module.exports.setup = (app) ->
req.user.update({$set: { enrollmentRequestSent: true }}).exec(_.noop) if req.body.recipientID is 'schools@codecombat.com'
closeIO.sendMail fromAddress, subject, content, (err) ->
log.error "Error sending contact form email via Close.io: #{err.message or err}" if err
else
else
createSendWithUsContext req, fromAddress, subject, content, (context) ->
sendwithus.api.send context, (err, result) ->
log.error "Error sending contact form email via sendwithus: #{err.message or err}" if err
@ -61,8 +61,7 @@ createSendWithUsContext = (req, fromAddress, subject, content, done) ->
else config.mail.supportPrimary
context =
email_id: sendwithus.templates.plain_text_email.id
version_name: sendwithus.templates.plain_text_email.version
email_id: sendwithus.templates.plain_text_email
recipient:
address: toAddress
sender:

View file

@ -592,8 +592,7 @@ sendLadderUpdateEmail = (session, now, daysAgo) ->
sendEmail = (defeatContext, victoryContext, levelVersionsContext) ->
# TODO: do something with the preferredLanguage?
context =
email_id: sendwithus.templates.ladder_update_email.id
version_name: sendwithus.templates.ladder_update_email.version
email_id: sendwithus.templates.ladder_update_email
recipient:
address: if DEBUGGING then 'nick@codecombat.com' else user.get('email')
name: name
@ -722,8 +721,7 @@ sendNextStepsEmail = (user, now, daysAgo) ->
# Used to use these categories to customize the email; not doing it right now. TODO: customize it again in Sendwithus.
# TODO: do something with the preferredLanguage?
context =
email_id: sendwithus.templates.next_steps_email.id
version_name: sendwithus.templates.next_steps_email.version
email_id: sendwithus.templates.next_steps_email
recipient:
address: if DEBUGGING then 'nick@codecombat.com' else user.get('email')
name: name

View file

@ -11,30 +11,26 @@ module.exports.api =
send: (context, cb) ->
log.debug('Tried to send email with context: ', JSON.stringify(context, null, ' '))
setTimeout(cb, 10)
if swuAPIKey
module.exports.api = new sendwithusAPI swuAPIKey, debug
# Version name can be supplied to tie a specific version to a deploy.
# That is most useful for testing templates with new data fields on staging.
# If it doesn't need to be synchronized to a deploy, you can just "publish"
# the new template version on SendWithUs (and leave this version blank)
module.exports.templates =
parent_subscribe_email: { id: 'tem_2APERafogvwKhmcnouigud' }
share_progress_email: { id: 'tem_VHE3ihhGmVa3727qds9zY8' }
welcome_email_user: { id: 'tem_z7Xvj3mtWYk6ec6aW7RwFk' }
welcome_email_student: { id: 'tem_4WYPZNLzs5wawMF9qUJXUH' }
verify_email: { id: 'tem_zJee6uRsRmzqzktzneCkCn' }
ladder_update_email: { id: 'JzaZxf39A4cKMxpPZUfWy4' }
patch_created: { id: 'tem_xhxuNosLALsizTNojBjNcL' }
change_made_notify_watcher: { id: 'tem_7KVkfmv9SZETb25dtHbUtG' }
recruiting_email: { id: 'tem_mdFMgtcczHKYu94Jmq68j8' }
greed_tournament_rank: { id: 'tem_c4KYnk2TriEkkZx5NqqGLG' }
generic_email: { id: 'tem_JhRnQ4pvTS4KdQjYoZdbei' }
plain_text_email: { id: 'tem_85UvKDCCNPXsFckERTig6Y' }
next_steps_email: { id: 'tem_RDHhTG5inXQi8pthyqWr5D' }
course_invite_email: { id: 'tem_u6D2EFWYC5Ptk38bSykjsU', version: 'v3' }
teacher_free_trial: { id: 'tem_R7d9Hpoba9SceQNiYSXBak' }
teacher_free_trial_hoc: { id: 'tem_4ZSY9wsA9Qwn4wBFmZgPdc' }
teacher_request_demo: { id: 'tem_cwG3HZjEyb6QE493hZuUra' }
password_reset: { id: 'tem_wbQUMRtLY9xhec8BSCykLA' }
parent_subscribe_email: 'tem_2APERafogvwKhmcnouigud'
share_progress_email: 'tem_VHE3ihhGmVa3727qds9zY8'
welcome_email_user: 'tem_z7Xvj3mtWYk6ec6aW7RwFk'
welcome_email_student: 'tem_4WYPZNLzs5wawMF9qUJXUH'
verify_email: 'tem_zJee6uRsRmzqzktzneCkCn'
ladder_update_email: 'JzaZxf39A4cKMxpPZUfWy4'
patch_created: 'tem_xhxuNosLALsizTNojBjNcL'
change_made_notify_watcher: 'tem_7KVkfmv9SZETb25dtHbUtG'
recruiting_email: 'tem_mdFMgtcczHKYu94Jmq68j8'
greed_tournament_rank: 'tem_c4KYnk2TriEkkZx5NqqGLG'
generic_email: 'tem_JhRnQ4pvTS4KdQjYoZdbei'
plain_text_email: 'tem_85UvKDCCNPXsFckERTig6Y'
next_steps_email: 'tem_RDHhTG5inXQi8pthyqWr5D'
course_invite_email: 'tem_ic2ZhPkpj8GBADFuyAp4bj'
teacher_free_trial: 'tem_R7d9Hpoba9SceQNiYSXBak'
teacher_free_trial_hoc: 'tem_4ZSY9wsA9Qwn4wBFmZgPdc'
teacher_request_demo: 'tem_cwG3HZjEyb6QE493hZuUra'
password_reset: 'tem_wbQUMRtLY9xhec8BSCykLA'

View file

@ -127,7 +127,7 @@ describe 'POST /db/article', ->
@admin = yield utils.initAdmin({})
yield utils.loginUser(@admin)
[@res, @body] = yield request.postAsync {
uri: getURL('/db/article'), json: articleData
uri: getURL('/db/article'), json: articleData
}
done()
@ -163,8 +163,8 @@ describe 'POST /db/article', ->
it 'returns 422 when properties do not pass validation', utils.wrap (done) ->
[res, body] = yield request.postAsync {
uri: getURL('/db/article'), json: { i18nCoverage: 9001 }
[res, body] = yield request.postAsync {
uri: getURL('/db/article'), json: { i18nCoverage: 9001 }
}
expect(res.statusCode).toBe(422)
expect(body.validationErrors).toBeDefined()
@ -461,7 +461,7 @@ describe 'POST /db/article/:handle/new-version', ->
it 'notifies watchers of changes', utils.wrap (done) ->
sendwithus = require '../../../server/sendwithus'
spyOn(sendwithus.api, 'send').and.callFake (context, cb) ->
expect(context.email_id).toBe(sendwithus.templates.change_made_notify_watcher.id)
expect(context.email_id).toBe(sendwithus.templates.change_made_notify_watcher)
expect(context.recipient.address).toBe('test@gmail.com')
done()
user = yield User({email: 'test@gmail.com', name: 'a user'}).save()

View file

@ -375,7 +375,7 @@ describe 'POST /db/classroom/:id/invite-members', ->
data = { emails: ['test@test.com'] }
sendwithus = require '../../../server/sendwithus'
spyOn(sendwithus.api, 'send').and.callFake (context, cb) ->
expect(context.email_id).toBe(sendwithus.templates.course_invite_email.id)
expect(context.email_id).toBe(sendwithus.templates.course_invite_email)
expect(context.recipient.address).toBe('test@test.com')
expect(context.email_data.teacher_name).toBe('Mr Professerson')
done()