diff --git a/.gitignore b/.gitignore index 629e1676e..d058d20d1 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,6 @@ coverage # ignore packages node_modules -package-lock.json \ No newline at end of file +package-lock.json + +*.dump diff --git a/Gemfile.lock b/Gemfile.lock index 7131f36e3..0da099209 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -293,7 +293,7 @@ GEM pry-rails (0.3.9) pry (>= 0.10.4) public_suffix (4.0.3) - puma (4.3.2) + puma (4.3.3) nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) diff --git a/app/controllers/api/v1/conversations/messages_controller.rb b/app/controllers/api/v1/conversations/messages_controller.rb index 22fdd88fb..793b3d054 100644 --- a/app/controllers/api/v1/conversations/messages_controller.rb +++ b/app/controllers/api/v1/conversations/messages_controller.rb @@ -1,8 +1,18 @@ class Api::V1::Conversations::MessagesController < Api::BaseController - before_action :set_conversation, only: [:create] + before_action :set_conversation, only: [:index, :create] + + def index + @messages = message_finder.perform + end def create mb = Messages::Outgoing::NormalBuilder.new(current_user, @conversation, params) @message = mb.perform end + + private + + def message_finder + @message_finder ||= MessageFinder.new(@conversation, params) + end end diff --git a/app/controllers/api/v1/conversations_controller.rb b/app/controllers/api/v1/conversations_controller.rb index 6c44114be..cf0d55779 100644 --- a/app/controllers/api/v1/conversations_controller.rb +++ b/app/controllers/api/v1/conversations_controller.rb @@ -7,9 +7,7 @@ class Api::V1::ConversationsController < Api::BaseController @conversations_count = result[:count] end - def show - @messages = messages_finder.perform - end + def show; end def toggle_status @status = @conversation.toggle_status @@ -34,8 +32,4 @@ class Api::V1::ConversationsController < Api::BaseController def conversation_finder @conversation_finder ||= ConversationFinder.new(current_user, params) end - - def messages_finder - @message_finder ||= MessageFinder.new(@conversation, params) - end end diff --git a/app/controllers/twitter/callbacks_controller.rb b/app/controllers/twitter/callbacks_controller.rb index 876720f26..a46c54821 100644 --- a/app/controllers/twitter/callbacks_controller.rb +++ b/app/controllers/twitter/callbacks_controller.rb @@ -1,5 +1,7 @@ class Twitter::CallbacksController < Twitter::BaseController def show + return redirect_to app_new_twitter_inbox_url if permitted_params[:denied] + @response = twitter_client.access_token( oauth_token: permitted_params[:oauth_token], oauth_verifier: permitted_params[:oauth_verifier] @@ -46,6 +48,6 @@ class Twitter::CallbacksController < Twitter::BaseController end def permitted_params - params.permit(:oauth_token, :oauth_verifier) + params.permit(:oauth_token, :oauth_verifier, :denied) end end diff --git a/app/javascript/dashboard/api/inbox/message.js b/app/javascript/dashboard/api/inbox/message.js index 367e3e00c..00dda8a63 100644 --- a/app/javascript/dashboard/api/inbox/message.js +++ b/app/javascript/dashboard/api/inbox/message.js @@ -15,7 +15,7 @@ class MessageApi extends ApiClient { } getPreviousMessages({ conversationId, before }) { - return axios.get(`${this.url}/${conversationId}`, { + return axios.get(`${this.url}/${conversationId}/messages`, { params: { before }, }); } diff --git a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue index 7e7bacfd2..fff476945 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ReplyBox.vue @@ -33,14 +33,18 @@
@@ -49,16 +53,12 @@ class="button send-button" :disabled="disableButton()" :class="{ - disabled: message.length === 0 || message.length > 640, + disabled: message.length === 0 || message.length > maxLength, warning: isPrivate, }" @click="sendMessage" > - {{ - isPrivate - ? $t('CONVERSATION.REPLYBOX.CREATE') - : $t('CONVERSATION.REPLYBOX.SEND') - }} + {{ replyButtonLabel }} this.initialize()); this.$watch('chatList.length', () => { + this.fetchConversation(); this.setActiveChat(); }); }, @@ -81,13 +82,28 @@ export default { break; default: this.$store.dispatch('setActiveInbox', null); + this.$store.dispatch('clearSelectedState'); break; } }, - setActiveChat() { + fetchConversation() { + if (!this.conversationId) { + return; + } + const chat = this.findConversation(); + if (!chat) { + this.$store.dispatch('getConversation', this.conversationId); + } + }, + findConversation() { const conversationId = parseInt(this.conversationId, 10); const [chat] = this.chatList.filter(c => c.id === conversationId); + return chat; + }, + + setActiveChat() { + const chat = this.findConversation(); if (!chat) return; this.$store.dispatch('setActiveChat', chat).then(() => { bus.$emit('scrollToMessage'); diff --git a/app/javascript/dashboard/routes/dashboard/conversation/conversation.routes.js b/app/javascript/dashboard/routes/dashboard/conversation/conversation.routes.js index b147fa6a2..f38cded3c 100644 --- a/app/javascript/dashboard/routes/dashboard/conversation/conversation.routes.js +++ b/app/javascript/dashboard/routes/dashboard/conversation/conversation.routes.js @@ -28,7 +28,7 @@ export default { roles: ['administrator', 'agent'], component: ConversationView, props: route => { - return { conversationId: route.params.conversation_id }; + return { inboxId: 0, conversationId: route.params.conversation_id }; }, }, { diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/Index.vue index 28eaa40de..c85436084 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/Index.vue @@ -39,6 +39,9 @@ Website + + Twitter + diff --git a/app/javascript/dashboard/routes/dashboard/settings/profile/EmailNotifications.vue b/app/javascript/dashboard/routes/dashboard/settings/profile/EmailNotifications.vue index b4053745c..5e4cbe227 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/profile/EmailNotifications.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/profile/EmailNotifications.vue @@ -1,9 +1,9 @@