Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threads #1312

Merged
merged 8 commits into from
Feb 7, 2017
Merged

Threads #1312

merged 8 commits into from
Feb 7, 2017

Conversation

vanstee
Copy link
Member

@vanstee vanstee commented Jan 19, 2017

Probably not going to end up merging this, but figured I'd open a PR for some discussion.

This PR makes Cog respond to the message it was sent with a new thread response. All we need to do is set thread_ts with the value of ts from the original message. There are still some issues on Slack's end to work out, like attachments missing from responses and such. Also on our end we need to disable this when redirecting to another room since threads can only be created and responded to in a single room. Either way, this was a cool experiment and was really only a minimal amount of work.

screen shot 2017-01-18 at 8 45 31 pm

@vanstee vanstee added the review label Jan 19, 2017
Copy link
Member

@kevsmith kevsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 👍 on getting this merged ASAP modulo the refinements listed in my review comments.

@@ -139,19 +139,19 @@ defmodule Cog.Chat.Adapter do
result
end

def send(provider, target, message) do
def send(provider, target, message, thread_id) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you think about replacing thread_id with an options keyword list?

def send(provider, target, message, opts \\ [])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. To keep our api surface area down it makes sense to always send our metadata field here whether or not it's empty. We can ignore it in the non-Slack adapters for now.

@@ -7,6 +7,7 @@ defmodule Cog.Chat.Message do
field :user, [object: Cog.Chat.User], required: true
field :text, :string, required: true
field :provider, :string, required: true
field :thread_id, :string, required: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above I'm thinking we should replace :thread_id with a metadata module and field like so:

field :metadata, [object: Cog.Chat.MessageMetadata], required: false

@vanstee vanstee force-pushed the vanstee/threads branch 3 times, most recently from 9ffb538 to b8b5cff Compare January 24, 2017 22:41
@vanstee
Copy link
Member Author

vanstee commented Jan 24, 2017

  • Moved thread_id to metadata included in each message
  • Added an env var SLACK_ENABLE_THREADED_RESPONSES to enable thread responses (disabled by default) as there are still some issues on Slack's end (rendering attachments are broken, dealing with thread_ts that can't be found, scrolling down and acking notifications related to thread responses).
  • Fixed a bug where thread responses broke when redirecting to other rooms

@vanstee vanstee force-pushed the vanstee/threads branch 2 times, most recently from 094680a to 482c9fc Compare January 26, 2017 05:47
Copy link
Collaborator

@christophermaier christophermaier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the overall look of things, but have a concern about the "metadata" implementation.

There aren't any tests, either, which gives me pause, particularly with such a new and apparently unfinished feature as threads are.

Maybe we should hold off on merging this until we have tests or threads mature a bit?

@@ -0,0 +1,6 @@
defmodule Cog.Chat.MessageMetadata do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some documentation on this module in particular would be nice, emphasizing that (for now, at least) it's a bit of a grab-bag of "stuff" that only really applies to Slack, and not more broadly.

On further reflection, I wonder if we're perhaps over-architecting things by making this a Conduit-validated module, particularly given its grab-bag nature. Maybe it should just be a keyword list until a broader and more general use case becomes apparent?

Copy link
Member

@kevsmith kevsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 to merge once the couple of logging tweaks are added.

case Cog.Chat.MessageMetadata.from_map(metadata) do
{:ok, metadata} ->
metadata
_error ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversion error should be logged.

%Cog.Chat.MessageMetadata{}
end
_ ->
%Cog.Chat.MessageMetadata{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should log that we're ignoring non-map metadata so future us doesn't go insane trying to figure out why metadata isn't getting included :)

@vanstee
Copy link
Member Author

vanstee commented Feb 6, 2017

Added logging and comments about the metadata struct.

@vanstee vanstee merged commit 08251de into master Feb 7, 2017
@vanstee vanstee deleted the vanstee/threads branch February 7, 2017 17:45
@vanstee vanstee removed the review label Feb 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants