getting_started_controller.rb 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. require 'resolv'
  3. class GettingStartedController < ApplicationController
  4. =begin
  5. Resource:
  6. GET /api/v1/getting_started
  7. Response:
  8. {
  9. "master_user": 1,
  10. "groups": [
  11. {
  12. "name": "group1",
  13. "active":true
  14. },
  15. {
  16. "name": "group2",
  17. "active":true
  18. }
  19. ]
  20. }
  21. Test:
  22. curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
  23. =end
  24. def index
  25. # check if first user already exists
  26. return if setup_done_response
  27. # check it auto wizard is already done
  28. auto_wizard_admin = AutoWizard.setup
  29. if auto_wizard_admin
  30. # set current session user
  31. current_user_set(auto_wizard_admin)
  32. # set system init to done
  33. Setting.set( 'system_init_done', true )
  34. render json: {
  35. auto_wizard: true,
  36. setup_done: setup_done,
  37. import_mode: Setting.get('import_mode'),
  38. import_backend: Setting.get('import_backend'),
  39. system_online_service: Setting.get('system_online_service'),
  40. }
  41. return
  42. end
  43. # if master user already exists, we need to be authenticated
  44. if setup_done
  45. return if !authentication_check
  46. end
  47. # return result
  48. render json: {
  49. setup_done: setup_done,
  50. import_mode: Setting.get('import_mode'),
  51. import_backend: Setting.get('import_backend'),
  52. system_online_service: Setting.get('system_online_service'),
  53. }
  54. end
  55. def base
  56. # check admin permissions
  57. return if deny_if_not_role(Z_ROLENAME_ADMIN)
  58. # validate url
  59. messages = {}
  60. if !Setting.get('system_online_service')
  61. if !params[:url] || params[:url] !~ %r{^(http|https)://.+?$}
  62. messages[:url] = 'A URL looks like http://zammad.example.com'
  63. end
  64. end
  65. # validate organization
  66. if !params[:organization] || params[:organization].empty?
  67. messages[:organization] = 'Invalid!'
  68. end
  69. # validate image
  70. if params[:logo] && params[:logo] =~ /^data:image/i
  71. file = StaticAssets.data_url_attributes( params[:logo] )
  72. if !file[:content] || !file[:mime_type]
  73. messages[:logo] = 'Unable to process image upload.'
  74. end
  75. end
  76. if !messages.empty?
  77. render json: {
  78. result: 'invalid',
  79. messages: messages,
  80. }
  81. return
  82. end
  83. # split url in http_type and fqdn
  84. settings = {}
  85. if !Setting.get('system_online_service')
  86. if params[:url] =~ %r{/^(http|https)://(.+?)$}
  87. Setting.set('http_type', $1)
  88. settings[:http_type] = $1
  89. Setting.set('fqdn', $2)
  90. settings[:fqdn] = $2
  91. end
  92. end
  93. # save organization
  94. Setting.set('organization', params[:organization])
  95. settings[:organization] = params[:organization]
  96. # save image
  97. if params[:logo] && params[:logo] =~ /^data:image/i
  98. # data:image/png;base64
  99. file = StaticAssets.data_url_attributes( params[:logo] )
  100. # store image 1:1
  101. StaticAssets.store_raw( file[:content], file[:mime_type] )
  102. end
  103. if params[:logo_resize] && params[:logo_resize] =~ /^data:image/i
  104. # data:image/png;base64
  105. file = StaticAssets.data_url_attributes( params[:logo_resize] )
  106. # store image 1:1
  107. settings[:product_logo] = StaticAssets.store( file[:content], file[:mime_type] )
  108. end
  109. # set changed settings
  110. settings.each {|key, value|
  111. Setting.set(key, value)
  112. }
  113. render json: {
  114. result: 'ok',
  115. settings: settings,
  116. }
  117. end
  118. def email_probe
  119. # check admin permissions
  120. return if deny_if_not_role(Z_ROLENAME_ADMIN)
  121. # validation
  122. user = nil
  123. domain = nil
  124. if params[:email] =~ /^(.+?)@(.+?)$/
  125. user = $1
  126. domain = $2
  127. end
  128. if !user || !domain
  129. render json: {
  130. result: 'invalid',
  131. messages: {
  132. email: 'Invalid email.'
  133. },
  134. }
  135. return
  136. end
  137. # check domain based attributes
  138. provider_map = {
  139. google: {
  140. domain: 'gmail.com|googlemail.com|gmail.de',
  141. inbound: {
  142. adapter: 'imap',
  143. options: {
  144. host: 'imap.gmail.com',
  145. port: '993',
  146. ssl: true,
  147. user: params[:email],
  148. password: params[:password],
  149. },
  150. },
  151. outbound: {
  152. adapter: 'smtp',
  153. options: {
  154. host: 'smtp.gmail.com',
  155. port: '25',
  156. start_tls: true,
  157. user: params[:email],
  158. password: params[:password],
  159. }
  160. },
  161. },
  162. microsoft: {
  163. domain: 'outlook.com|hotmail.com',
  164. inbound: {
  165. adapter: 'imap',
  166. options: {
  167. host: 'imap-mail.outlook.com',
  168. port: '993',
  169. ssl: true,
  170. user: params[:email],
  171. password: params[:password],
  172. },
  173. },
  174. outbound: {
  175. adapter: 'smtp',
  176. options: {
  177. host: 'smtp-mail.outlook.com',
  178. port: 25,
  179. start_tls: true,
  180. user: params[:email],
  181. password: params[:password],
  182. }
  183. },
  184. },
  185. }
  186. # probe based on email domain and mx
  187. domains = [domain]
  188. mail_exchangers = mxers(domain)
  189. if mail_exchangers && mail_exchangers[0]
  190. logger.info "MX for #{domain}: #{mail_exchangers} - #{mail_exchangers[0][0]}"
  191. end
  192. if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
  193. domains.push mail_exchangers[0][0]
  194. end
  195. provider_map.each {|provider, settings|
  196. domains.each {|domain_to_check|
  197. if domain_to_check =~ /#{settings[:domain]}/i
  198. # probe inbound
  199. result = email_probe_inbound( settings[:inbound] )
  200. if result[:result] != 'ok'
  201. render json: result
  202. return
  203. end
  204. # probe outbound
  205. result = email_probe_outbound( settings[:outbound], params[:email] )
  206. if result[:result] != 'ok'
  207. render json: result
  208. return
  209. end
  210. render json: {
  211. result: 'ok',
  212. setting: settings,
  213. }
  214. return
  215. end
  216. }
  217. }
  218. # probe inbound
  219. inbound_map = []
  220. if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
  221. inbound_mx = [
  222. {
  223. adapter: 'imap',
  224. options: {
  225. host: mail_exchangers[0][0],
  226. port: 993,
  227. ssl: true,
  228. user: user,
  229. password: params[:password],
  230. },
  231. },
  232. {
  233. adapter: 'imap',
  234. options: {
  235. host: mail_exchangers[0][0],
  236. port: 993,
  237. ssl: true,
  238. user: params[:email],
  239. password: params[:password],
  240. },
  241. },
  242. ]
  243. inbound_map = inbound_map + inbound_mx
  244. end
  245. inbound_auto = [
  246. {
  247. adapter: 'imap',
  248. options: {
  249. host: "mail.#{domain}",
  250. port: 993,
  251. ssl: true,
  252. user: user,
  253. password: params[:password],
  254. },
  255. },
  256. {
  257. adapter: 'imap',
  258. options: {
  259. host: "mail.#{domain}",
  260. port: 993,
  261. ssl: true,
  262. user: params[:email],
  263. password: params[:password],
  264. },
  265. },
  266. {
  267. adapter: 'imap',
  268. options: {
  269. host: "imap.#{domain}",
  270. port: 993,
  271. ssl: true,
  272. user: user,
  273. password: params[:password],
  274. },
  275. },
  276. {
  277. adapter: 'imap',
  278. options: {
  279. host: "imap.#{domain}",
  280. port: 993,
  281. ssl: true,
  282. user: params[:email],
  283. password: params[:password],
  284. },
  285. },
  286. {
  287. adapter: 'pop3',
  288. options: {
  289. host: "mail.#{domain}",
  290. port: 995,
  291. ssl: true,
  292. user: user,
  293. password: params[:password],
  294. },
  295. },
  296. {
  297. adapter: 'pop3',
  298. options: {
  299. host: "mail.#{domain}",
  300. port: 995,
  301. ssl: true,
  302. user: params[:email],
  303. password: params[:password],
  304. },
  305. },
  306. {
  307. adapter: 'pop3',
  308. options: {
  309. host: "pop.#{domain}",
  310. port: 995,
  311. ssl: true,
  312. user: user,
  313. password: params[:password],
  314. },
  315. },
  316. {
  317. adapter: 'pop3',
  318. options: {
  319. host: "pop.#{domain}",
  320. port: 995,
  321. ssl: true,
  322. user: params[:email],
  323. password: params[:password],
  324. },
  325. },
  326. {
  327. adapter: 'pop3',
  328. options: {
  329. host: "pop3.#{domain}",
  330. port: 995,
  331. ssl: true,
  332. user: user,
  333. password: params[:password],
  334. },
  335. },
  336. {
  337. adapter: 'pop3',
  338. options: {
  339. host: "pop3.#{domain}",
  340. port: 995,
  341. ssl: true,
  342. user: params[:email],
  343. password: params[:password],
  344. },
  345. },
  346. ]
  347. inbound_map = inbound_map + inbound_auto
  348. settings = {}
  349. success = false
  350. inbound_map.each {|config|
  351. logger.info "INBOUND PROBE: #{config.inspect}"
  352. result = email_probe_inbound( config )
  353. logger.info "INBOUND RESULT: #{result.inspect}"
  354. if result[:result] == 'ok'
  355. success = true
  356. settings[:inbound] = config
  357. break
  358. end
  359. }
  360. if !success
  361. render json: {
  362. result: 'failed',
  363. }
  364. return
  365. end
  366. # probe outbound
  367. outbound_map = []
  368. if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
  369. outbound_mx = [
  370. {
  371. adapter: 'smtp',
  372. options: {
  373. host: mail_exchangers[0][0],
  374. port: 25,
  375. start_tls: true,
  376. user: user,
  377. password: params[:password],
  378. },
  379. },
  380. {
  381. adapter: 'smtp',
  382. options: {
  383. host: mail_exchangers[0][0],
  384. port: 25,
  385. start_tls: true,
  386. user: params[:email],
  387. password: params[:password],
  388. },
  389. },
  390. {
  391. adapter: 'smtp',
  392. options: {
  393. host: mail_exchangers[0][0],
  394. port: 465,
  395. start_tls: true,
  396. user: user,
  397. password: params[:password],
  398. },
  399. },
  400. {
  401. adapter: 'smtp',
  402. options: {
  403. host: mail_exchangers[0][0],
  404. port: 465,
  405. start_tls: true,
  406. user: params[:email],
  407. password: params[:password],
  408. },
  409. },
  410. ]
  411. outbound_map = outbound_map + outbound_mx
  412. end
  413. outbound_auto = [
  414. {
  415. adapter: 'smtp',
  416. options: {
  417. host: "mail.#{domain}",
  418. port: 25,
  419. start_tls: true,
  420. user: user,
  421. password: params[:password],
  422. },
  423. },
  424. {
  425. adapter: 'smtp',
  426. options: {
  427. host: "mail.#{domain}",
  428. port: 25,
  429. start_tls: true,
  430. user: params[:email],
  431. password: params[:password],
  432. },
  433. },
  434. {
  435. adapter: 'smtp',
  436. options: {
  437. host: "mail.#{domain}",
  438. port: 465,
  439. start_tls: true,
  440. user: user,
  441. password: params[:password],
  442. },
  443. },
  444. {
  445. adapter: 'smtp',
  446. options: {
  447. host: "mail.#{domain}",
  448. port: 465,
  449. start_tls: true,
  450. user: params[:email],
  451. password: params[:password],
  452. },
  453. },
  454. {
  455. adapter: 'smtp',
  456. options: {
  457. host: "smtp.#{domain}",
  458. port: 25,
  459. start_tls: true,
  460. user: user,
  461. password: params[:password],
  462. },
  463. },
  464. {
  465. adapter: 'smtp',
  466. options: {
  467. host: "smtp.#{domain}",
  468. port: 25,
  469. start_tls: true,
  470. user: params[:email],
  471. password: params[:password],
  472. },
  473. },
  474. {
  475. adapter: 'smtp',
  476. options: {
  477. host: "smtp.#{domain}",
  478. port: 465,
  479. start_tls: true,
  480. user: user,
  481. password: params[:password],
  482. },
  483. },
  484. {
  485. adapter: 'smtp',
  486. options: {
  487. host: "smtp.#{domain}",
  488. port: 465,
  489. start_tls: true,
  490. user: params[:email],
  491. password: params[:password],
  492. },
  493. },
  494. ]
  495. success = false
  496. outbound_map.each {|config|
  497. logger.info "OUTBOUND PROBE: #{config.inspect}"
  498. result = email_probe_outbound( config, params[:email] )
  499. logger.info "OUTBOUND RESULT: #{result.inspect}"
  500. if result[:result] == 'ok'
  501. success = true
  502. settings[:outbound] = config
  503. break
  504. end
  505. }
  506. if !success
  507. render json: {
  508. result: 'failed',
  509. }
  510. return
  511. end
  512. render json: {
  513. result: 'ok',
  514. setting: settings,
  515. }
  516. end
  517. def email_outbound
  518. # check admin permissions
  519. return if deny_if_not_role(Z_ROLENAME_ADMIN)
  520. # validate params
  521. if !params[:adapter]
  522. render json: {
  523. result: 'invalid',
  524. }
  525. return
  526. end
  527. # connection test
  528. result = email_probe_outbound( params, params[:email] )
  529. render json: result
  530. end
  531. def email_inbound
  532. # check admin permissions
  533. return if deny_if_not_role(Z_ROLENAME_ADMIN)
  534. # validate params
  535. if !params[:adapter]
  536. render json: {
  537. result: 'invalid',
  538. }
  539. return
  540. end
  541. # connection test
  542. result = email_probe_inbound( params )
  543. render json: result
  544. end
  545. def email_verify
  546. # check admin permissions
  547. return if deny_if_not_role(Z_ROLENAME_ADMIN)
  548. # send verify email to inbox
  549. if !params[:subject]
  550. subject = '#' + rand(99_999_999_999).to_s
  551. else
  552. subject = params[:subject]
  553. end
  554. result = email_probe_outbound( params[:outbound], params[:meta][:email], subject )
  555. (1..5).each {|loop|
  556. sleep 10
  557. # fetch mailbox
  558. found = nil
  559. begin
  560. if params[:inbound][:adapter] =~ /^imap$/i
  561. found = Channel::IMAP.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
  562. else
  563. found = Channel::POP3.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
  564. end
  565. rescue Exception => e
  566. render json: {
  567. result: 'invalid',
  568. message: e.to_s,
  569. subject: subject,
  570. }
  571. return
  572. end
  573. if found && found == 'verify ok'
  574. # remember address
  575. address = EmailAddress.where( email: params[:meta][:email] ).first
  576. if !address
  577. address = EmailAddress.first
  578. end
  579. if address
  580. address.update_attributes(
  581. realname: params[:meta][:realname],
  582. email: params[:meta][:email],
  583. active: 1,
  584. updated_by_id: 1,
  585. created_by_id: 1,
  586. )
  587. else
  588. EmailAddress.create(
  589. realname: params[:meta][:realname],
  590. email: params[:meta][:email],
  591. active: 1,
  592. updated_by_id: 1,
  593. created_by_id: 1,
  594. )
  595. end
  596. # store mailbox
  597. Channel.create(
  598. area: 'Email::Inbound',
  599. adapter: params[:inbound][:adapter],
  600. options: params[:inbound][:options],
  601. group_id: 1,
  602. active: 1,
  603. updated_by_id: 1,
  604. created_by_id: 1,
  605. )
  606. # save settings
  607. if params[:outbound][:adapter] =~ /^smtp$/i
  608. smtp = Channel.where( adapter: 'SMTP', area: 'Email::Outbound' ).first
  609. smtp.options = params[:outbound][:options]
  610. smtp.active = true
  611. smtp.save!
  612. sendmail = Channel.where( adapter: 'Sendmail' ).first
  613. sendmail.active = false
  614. sendmail.save!
  615. else
  616. sendmail = Channel.where( adapter: 'Sendmail', area: 'Email::Outbound' ).first
  617. sendmail.options = {}
  618. sendmail.active = true
  619. sendmail.save!
  620. smtp = Channel.where( adapter: 'SMTP' ).first
  621. smtp.active = false
  622. smtp.save
  623. end
  624. render json: {
  625. result: 'ok',
  626. }
  627. return
  628. end
  629. }
  630. # check delivery for 30 sek.
  631. render json: {
  632. result: 'invalid',
  633. message: 'Verification Email not found in mailbox.',
  634. subject: subject,
  635. }
  636. end
  637. private
  638. def email_probe_outbound(params, email, subject = nil)
  639. # validate params
  640. if !params[:adapter]
  641. result = {
  642. result: 'invalid',
  643. message: 'Invalid, need adapter!',
  644. }
  645. return result
  646. end
  647. if subject
  648. mail = {
  649. :from => email,
  650. :to => email,
  651. :subject => "Zammad Getting started Test Email #{subject}",
  652. :body => "This is a Test Email of Zammad to check if sending and receiving is working correctly.\n\nYou can ignore or delete this email.",
  653. 'x-zammad-ignore' => 'true',
  654. }
  655. else
  656. mail = {
  657. from: email,
  658. to: 'emailtrytest@znuny.com',
  659. subject: 'test',
  660. body: 'test',
  661. }
  662. end
  663. # test connection
  664. translation_map = {
  665. 'authentication failed' => 'Authentication failed!',
  666. 'Incorrect username' => 'Authentication failed!',
  667. 'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
  668. 'No route to host' => 'No route to host!',
  669. 'Connection refused' => 'Connection refused!',
  670. }
  671. if params[:adapter] =~ /^smtp$/i
  672. # in case, fill missing params
  673. if !params[:options].key?(:port)
  674. params[:options][:port] = 25
  675. end
  676. if !params[:options].key?(:ssl)
  677. params[:options][:ssl] = true
  678. end
  679. begin
  680. Channel::SMTP.new.send(
  681. mail,
  682. {
  683. options: params[:options]
  684. }
  685. )
  686. rescue Exception => e
  687. # check if sending email was ok, but mailserver rejected
  688. if !subject
  689. white_map = {
  690. 'Recipient address rejected' => true,
  691. }
  692. white_map.each {|key, message|
  693. if e.message =~ /#{Regexp.escape(key)}/i
  694. result = {
  695. result: 'ok',
  696. settings: params,
  697. notice: e.message,
  698. }
  699. return result
  700. end
  701. }
  702. end
  703. message_human = ''
  704. translation_map.each {|key, message|
  705. if e.message =~ /#{Regexp.escape(key)}/i
  706. message_human = message
  707. end
  708. }
  709. result = {
  710. result: 'invalid',
  711. settings: params,
  712. message: e.message,
  713. message_human: message_human,
  714. }
  715. return result
  716. end
  717. result = {
  718. result: 'ok',
  719. }
  720. return result
  721. end
  722. begin
  723. Channel::Sendmail.new.send(
  724. mail,
  725. nil
  726. )
  727. rescue Exception => e
  728. message_human = ''
  729. translation_map.each {|key, message|
  730. if e.message =~ /#{Regexp.escape(key)}/i
  731. message_human = message
  732. end
  733. }
  734. result = {
  735. result: 'invalid',
  736. settings: params,
  737. message: e.message,
  738. message_human: message_human,
  739. }
  740. return result
  741. end
  742. result = {
  743. result: 'ok',
  744. }
  745. result
  746. end
  747. def email_probe_inbound(params)
  748. # validate params
  749. if !params[:adapter]
  750. raise 'need :adapter param'
  751. end
  752. # connection test
  753. translation_map = {
  754. 'authentication failed' => 'Authentication failed!',
  755. 'Incorrect username' => 'Authentication failed!',
  756. 'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
  757. 'No route to host' => 'No route to host!',
  758. 'Connection refused' => 'Connection refused!',
  759. }
  760. if params[:adapter] =~ /^imap$/i
  761. begin
  762. Channel::IMAP.new.fetch( { options: params[:options] }, 'check' )
  763. rescue Exception => e
  764. message_human = ''
  765. translation_map.each {|key, message|
  766. if e.message =~ /#{Regexp.escape(key)}/i
  767. message_human = message
  768. end
  769. }
  770. result = {
  771. result: 'invalid',
  772. settings: params,
  773. message: e.message,
  774. message_human: message_human,
  775. }
  776. return result
  777. end
  778. result = {
  779. result: 'ok',
  780. }
  781. return result
  782. end
  783. begin
  784. Channel::POP3.new.fetch( { options: params[:options] }, 'check' )
  785. rescue Exception => e
  786. message_human = ''
  787. translation_map.each {|key, message|
  788. if e.message =~ /#{Regexp.escape(key)}/i
  789. message_human = message
  790. end
  791. }
  792. result = {
  793. result: 'invalid',
  794. settings: params,
  795. message: e.message,
  796. message_human: message_human,
  797. }
  798. return result
  799. end
  800. result = {
  801. result: 'ok',
  802. }
  803. result
  804. end
  805. def mxers(domain)
  806. begin
  807. mxs = Resolv::DNS.open do |dns|
  808. ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
  809. ress.map { |r| [r.exchange.to_s, IPSocket::getaddress(r.exchange.to_s), r.preference] }
  810. end
  811. rescue Exception => e
  812. logger.error e.message
  813. logger.error e.backtrace.inspect
  814. end
  815. mxs
  816. end
  817. def setup_done
  818. #return false
  819. count = User.all.count()
  820. done = true
  821. if count <= 2
  822. done = false
  823. end
  824. done
  825. end
  826. def setup_done_response
  827. if !setup_done
  828. return false
  829. end
  830. # get all groups
  831. groups = Group.where( active: true )
  832. # get email addresses
  833. addresses = EmailAddress.where( active: true )
  834. render json: {
  835. setup_done: true,
  836. import_mode: Setting.get('import_mode'),
  837. import_backend: Setting.get('import_backend'),
  838. system_online_service: Setting.get('system_online_service'),
  839. addresses: addresses,
  840. groups: groups,
  841. }
  842. true
  843. end
  844. end