Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
api for user messaging history
Browse files Browse the repository at this point in the history
  • Loading branch information
wuminzhe committed May 11, 2024
1 parent fd2519b commit 7afd5ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ def timespent
end
end

def sent_by

respond_to do |format|
format.html {
@messages = Message.where(msgport_from: params[:msgport_from]).order(block_timestamp: :desc).page(params[:page]).per(25)
@messages_count = @messages.count
render :index
}
format.json {
@messages = Message.where(msgport_from: params[:msgport_from]).order(block_timestamp: :desc)

render json: @messages
}
end
end

private

# Use callbacks to share common setup or constraints between actions.
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
get 'messages/timespent/:op/:number/:unit' => 'messages#timespent',
as: :messages_timespent

get 'messages/sent_by/:msgport_from' => 'messages#sent_by'

get 'messages/:tx_or_hash' => 'messages#show',
as: :message_by_tx_or_hash,
constraints: { tx_or_hash: /0x[0-9a-fA-F]{64}/ }
Expand Down

0 comments on commit 7afd5ef

Please sign in to comment.