I'm starting a sidekiq-job in background which updates the users newsletter_info async in background via after_commit callback. So if a user updates his language in his settings, the language got updated in MailChimp too. Everything works fine except the emailadresse. If a users updates his emailadresse it will be shown in the log messages and it will be at the right place but it will not be updated in mailchimp. Instead a new user with the new emailaddress gets adeed to the mailchimp list...
So one option might be to delete the old one, but i think that solution is not clean.
My other thought is that maybe the emailadresse is although the subscriber id and there the error might be born.
Thank you very much for your help,
Regards, Khaled.
def update_newsletter_info(args)
NDC.push "KHALED -- "
Rails.logger.debug "UPDATENEWSLETTERINFO ARGS: #{args}"
XIXI::Workflow.for(TwitterUsersMaintainer, args) do |workflow, user|
Rails.logger.debug "INFOS IN UPDATENEWSLETTERINFO #{user.locale} #{user.email}"
gb = Gibbon::API.new
cfg = XOXO::Mailchimp.config
gb.lists.subscribe(
:id => cfg.list_id,
:email => { :email => user.email },
:merge_vars => {
:mc_language => user.locale,
:groupings => [
{ name: cfg.group_name, groups: [ user.recurring_payment? ? 'basic' : 'free' ] }
]
},
:double_optin => !!cfg.double_optin,
:update_existing => true,
:send_welcome => !!cfg.send_welcome
)
# continue
workflow.continue_with(user)
end
NDC.pop
end