activity_stream_controller.rb 941 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class ActivityStreamController < ApplicationController
  3. prepend_before_action :authentication_check
  4. # GET /api/v1/activity_stream
  5. def show
  6. activity_stream = current_user.activity_stream(params[:limit])
  7. if response_expand?
  8. list = []
  9. activity_stream.each do |item|
  10. list.push item.attributes_with_association_names
  11. end
  12. render json: list, status: :ok
  13. return
  14. end
  15. if response_full?
  16. assets = {}
  17. item_ids = []
  18. activity_stream.each do |item|
  19. item_ids.push item.id
  20. assets = item.assets(assets)
  21. end
  22. render json: {
  23. record_ids: item_ids,
  24. assets: assets,
  25. }, status: :ok
  26. return
  27. end
  28. all = []
  29. activity_stream.each do |item|
  30. all.push item.attributes_with_association_ids
  31. end
  32. render json: all, status: :ok
  33. end
  34. end