activity_stream_controller.rb 848 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://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 = activity_stream.map(&:attributes_with_association_names)
  9. render json: list, status: :ok
  10. return
  11. end
  12. if response_full?
  13. assets = {}
  14. item_ids = []
  15. activity_stream.each do |item|
  16. item_ids.push item.id
  17. assets = item.assets(assets)
  18. end
  19. render json: {
  20. record_ids: item_ids,
  21. assets: assets,
  22. }, status: :ok
  23. return
  24. end
  25. all = activity_stream.map(&:attributes_with_association_ids)
  26. render json: all, status: :ok
  27. end
  28. end