getting_started_controller.rb 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936
  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] !~ /^(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] =~ /^(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. providerMap = {
  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. providerMap.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. inboundMap = []
  220. if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
  221. inboundMx = [
  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. inboundMap = inboundMap + inboundMx
  244. end
  245. inboundAuto = [
  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. inboundMap = inboundMap + inboundAuto
  348. settings = {}
  349. success = false
  350. inboundMap.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. outboundMap = []
  368. if mail_exchangers && mail_exchangers[0] && mail_exchangers[0][0]
  369. outboundMx = [
  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. outboundMap = outboundMap + outboundMx
  412. end
  413. outboundAuto = [
  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. outboundMap.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. return
  545. end
  546. def email_verify
  547. # check admin permissions
  548. return if deny_if_not_role(Z_ROLENAME_ADMIN)
  549. # send verify email to inbox
  550. if !params[:subject]
  551. subject = '#' + rand(99_999_999_999).to_s
  552. else
  553. subject = params[:subject]
  554. end
  555. result = email_probe_outbound( params[:outbound], params[:meta][:email], subject )
  556. (1..5).each {|loop|
  557. sleep 10
  558. # fetch mailbox
  559. found = nil
  560. begin
  561. if params[:inbound][:adapter] =~ /^imap$/i
  562. found = Channel::IMAP.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
  563. else
  564. found = Channel::POP3.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
  565. end
  566. rescue Exception => e
  567. render json: {
  568. result: 'invalid',
  569. message: e.to_s,
  570. subject: subject,
  571. }
  572. return
  573. end
  574. if found && found == 'verify ok'
  575. # remember address
  576. address = EmailAddress.where( email: params[:meta][:email] ).first
  577. if !address
  578. address = EmailAddress.first
  579. end
  580. if address
  581. address.update_attributes(
  582. realname: params[:meta][:realname],
  583. email: params[:meta][:email],
  584. active: 1,
  585. updated_by_id: 1,
  586. created_by_id: 1,
  587. )
  588. else
  589. EmailAddress.create(
  590. realname: params[:meta][:realname],
  591. email: params[:meta][:email],
  592. active: 1,
  593. updated_by_id: 1,
  594. created_by_id: 1,
  595. )
  596. end
  597. # store mailbox
  598. Channel.create(
  599. area: 'Email::Inbound',
  600. adapter: params[:inbound][:adapter],
  601. options: params[:inbound][:options],
  602. group_id: 1,
  603. active: 1,
  604. updated_by_id: 1,
  605. created_by_id: 1,
  606. )
  607. # save settings
  608. if params[:outbound][:adapter] =~ /^smtp$/i
  609. smtp = Channel.where( adapter: 'SMTP', area: 'Email::Outbound' ).first
  610. smtp.options = params[:outbound][:options]
  611. smtp.active = true
  612. smtp.save!
  613. sendmail = Channel.where( adapter: 'Sendmail' ).first
  614. sendmail.active = false
  615. sendmail.save!
  616. else
  617. sendmail = Channel.where( adapter: 'Sendmail', area: 'Email::Outbound' ).first
  618. sendmail.options = {}
  619. sendmail.active = true
  620. sendmail.save!
  621. smtp = Channel.where( adapter: 'SMTP' ).first
  622. smtp.active = false
  623. smtp.save
  624. end
  625. render json: {
  626. result: 'ok',
  627. }
  628. return
  629. end
  630. }
  631. # check delivery for 30 sek.
  632. render json: {
  633. result: 'invalid',
  634. message: 'Verification Email not found in mailbox.',
  635. subject: subject,
  636. }
  637. end
  638. private
  639. def email_probe_outbound(params, email, subject = nil)
  640. # validate params
  641. if !params[:adapter]
  642. result = {
  643. result: 'invalid',
  644. message: 'Invalid, need adapter!',
  645. }
  646. return result
  647. end
  648. if subject
  649. mail = {
  650. :from => email,
  651. :to => email,
  652. :subject => "Zammad Getting started Test Email #{subject}",
  653. :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.",
  654. 'x-zammad-ignore' => 'true',
  655. }
  656. else
  657. mail = {
  658. from: email,
  659. to: 'emailtrytest@znuny.com',
  660. subject: 'test',
  661. body: 'test',
  662. }
  663. end
  664. # test connection
  665. translationMap = {
  666. 'authentication failed' => 'Authentication failed!',
  667. 'Incorrect username' => 'Authentication failed!',
  668. 'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
  669. 'No route to host' => 'No route to host!',
  670. 'Connection refused' => 'Connection refused!',
  671. }
  672. if params[:adapter] =~ /^smtp$/i
  673. # in case, fill missing params
  674. if !params[:options].has_key?(:port)
  675. params[:options][:port] = 25
  676. end
  677. if !params[:options].has_key?(:ssl)
  678. params[:options][:ssl] = true
  679. end
  680. begin
  681. Channel::SMTP.new.send(
  682. mail,
  683. {
  684. options: params[:options]
  685. }
  686. )
  687. rescue Exception => e
  688. # check if sending email was ok, but mailserver rejected
  689. if !subject
  690. whiteMap = {
  691. 'Recipient address rejected' => true,
  692. }
  693. whiteMap.each {|key, message|
  694. if e.message =~ /#{Regexp.escape(key)}/i
  695. result = {
  696. result: 'ok',
  697. settings: params,
  698. notice: e.message,
  699. }
  700. return result
  701. end
  702. }
  703. end
  704. message_human = ''
  705. translationMap.each {|key, message|
  706. if e.message =~ /#{Regexp.escape(key)}/i
  707. message_human = message
  708. end
  709. }
  710. result = {
  711. result: 'invalid',
  712. settings: params,
  713. message: e.message,
  714. message_human: message_human,
  715. }
  716. return result
  717. end
  718. result = {
  719. result: 'ok',
  720. }
  721. return result
  722. end
  723. begin
  724. Channel::Sendmail.new.send(
  725. mail,
  726. nil
  727. )
  728. rescue Exception => e
  729. message_human = ''
  730. translationMap.each {|key, message|
  731. if e.message =~ /#{Regexp.escape(key)}/i
  732. message_human = message
  733. end
  734. }
  735. result = {
  736. result: 'invalid',
  737. settings: params,
  738. message: e.message,
  739. message_human: message_human,
  740. }
  741. return result
  742. end
  743. result = {
  744. result: 'ok',
  745. }
  746. return result
  747. end
  748. def email_probe_inbound(params)
  749. # validate params
  750. if !params[:adapter]
  751. raise 'need :adapter param'
  752. end
  753. # connection test
  754. translationMap = {
  755. 'authentication failed' => 'Authentication failed!',
  756. 'Incorrect username' => 'Authentication failed!',
  757. 'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
  758. 'No route to host' => 'No route to host!',
  759. 'Connection refused' => 'Connection refused!',
  760. }
  761. if params[:adapter] =~ /^imap$/i
  762. begin
  763. Channel::IMAP.new.fetch( { options: params[:options] }, 'check' )
  764. rescue Exception => e
  765. message_human = ''
  766. translationMap.each {|key, message|
  767. if e.message =~ /#{Regexp.escape(key)}/i
  768. message_human = message
  769. end
  770. }
  771. result = {
  772. result: 'invalid',
  773. settings: params,
  774. message: e.message,
  775. message_human: message_human,
  776. }
  777. return result
  778. end
  779. result = {
  780. result: 'ok',
  781. }
  782. return result
  783. end
  784. begin
  785. Channel::POP3.new.fetch( { options: params[:options] }, 'check' )
  786. rescue Exception => e
  787. message_human = ''
  788. translationMap.each {|key, message|
  789. if e.message =~ /#{Regexp.escape(key)}/i
  790. message_human = message
  791. end
  792. }
  793. result = {
  794. result: 'invalid',
  795. settings: params,
  796. message: e.message,
  797. message_human: message_human,
  798. }
  799. return result
  800. end
  801. result = {
  802. result: 'ok',
  803. }
  804. return result
  805. end
  806. def mxers(domain)
  807. begin
  808. mxs = Resolv::DNS.open do |dns|
  809. ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
  810. ress.map { |r| [r.exchange.to_s, IPSocket::getaddress(r.exchange.to_s), r.preference] }
  811. end
  812. rescue Exception => e
  813. logger.error e.message
  814. logger.error e.backtrace.inspect
  815. end
  816. mxs
  817. end
  818. def setup_done
  819. #return false
  820. count = User.all.count()
  821. done = true
  822. if count <= 2
  823. done = false
  824. end
  825. done
  826. end
  827. def setup_done_response
  828. if !setup_done
  829. return false
  830. end
  831. # get all groups
  832. groups = Group.where( active: true )
  833. # get email addresses
  834. addresses = EmailAddress.where( active: true )
  835. render json: {
  836. setup_done: true,
  837. import_mode: Setting.get('import_mode'),
  838. import_backend: Setting.get('import_backend'),
  839. system_online_service: Setting.get('system_online_service'),
  840. addresses: addresses,
  841. groups: groups,
  842. }
  843. true
  844. end
  845. end