17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/models/wechat/model/template_config/template_public.rb', line 17
def sync_key_words
if tid.present? && app
template = app.api.templates.find { |i| i['template_id'] == tid }
if template.blank?
result = app.api.add_template tid
template = app.api.templates.find { |i| i['template_id'] == result['template_id'] }
app.api.del_template result['template_id']
end
self.update content: template['content']
end
return if content.blank?
data_keys = Template.new(content: content).data_keys
data_keys.each do |key|
tkw = template_key_words.find_or_initialize_by(name: key)
tkw.save
end
end
|