···78 [:likes, :reposts, :quotes, :pins].map { |x| self.send(x).in_queue(queue).to_a }.reduce(&:+)
79 end
8081+ def imported_until
82+ return nil unless self.imports.exists?
83+84+ oldest_imported_items = []
85+ started = false
86+87+ [:likes, :reposts, :pins, :quotes].each do |group|
88+ if self.send(group).where(queue: :import).exists?
89+ oldest_imported_items << self.send(group).where(queue: nil).order(:time).first
90+ end
91+ end
92+93+ earliest_oldest = oldest_imported_items.compact.sort_by(&:time).last
94+95+ if earliest_oldest
96+ earliest_oldest.time
97+ elsif self.imports.merge(Import.unfinished).exists?
98+ nil
99+ else
100+ :end
101+ end
102+ end
103+104 def delete_posts_cascading
105 posts_subquery = self.posts.select(:id)
106
+20-1
app/server.rb
···38 end
3940 begin
41- did = @authenticator.decode_user_from_jwt(auth_header, 'blue.feeds.lycan.searchPosts')
042 rescue StandardError => e
43 halt json_error('InvalidToken', e.message, status: 401)
44 end
···110 end
111112 json_response(terms: query.terms, posts: post_uris, cursor: items.last&.cursor)
000000000000000000113 end
114115 get '/.well-known/did.json' do
···38 end
3940 begin
41+ method = request.path.split('/')[2]
42+ did = @authenticator.decode_user_from_jwt(auth_header, method)
43 rescue StandardError => e
44 halt json_error('InvalidToken', e.message, status: 401)
45 end
···111 end
112113 json_response(terms: query.terms, posts: post_uris, cursor: items.last&.cursor)
114+ end
115+116+ get '/xrpc/blue.feeds.lycan.getImportStatus' do
117+ headers['access-control-allow-origin'] = '*'
118+119+ did = get_user_did
120+ user = User.find_by(did: did)
121+ until_date = user&.imported_until
122+123+ case until_date
124+ when nil
125+ json_response(status: 'not_started')
126+ when :end
127+ json_response(status: 'finished')
128+ else
129+ progress = 1 - (until_date - user.registered_at) / (Time.now - user.registered_at)
130+ json_response(status: 'in_progress', position: until_date.iso8601, progress: progress)
131+ end
132 end
133134 get '/.well-known/did.json' do