-
Notifications
You must be signed in to change notification settings - Fork 71
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
Threads #1312
Conversation
There was a problem hiding this 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.
lib/cog/chat/adapter.ex
Outdated
@@ -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 |
There was a problem hiding this comment.
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 \\ [])
There was a problem hiding this comment.
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.
lib/cog/chat/message.ex
Outdated
@@ -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 |
There was a problem hiding this comment.
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
9ffb538
to
b8b5cff
Compare
|
094680a
to
482c9fc
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
482c9fc
to
b59cb69
Compare
b59cb69
to
74ba414
Compare
There was a problem hiding this 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.
lib/cog/chat/adapter.ex
Outdated
case Cog.Chat.MessageMetadata.from_map(metadata) do | ||
{:ok, metadata} -> | ||
metadata | ||
_error -> |
There was a problem hiding this comment.
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.
lib/cog/chat/adapter.ex
Outdated
%Cog.Chat.MessageMetadata{} | ||
end | ||
_ -> | ||
%Cog.Chat.MessageMetadata{} |
There was a problem hiding this comment.
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 :)
Added logging and comments about the metadata struct. |
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 ofts
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.