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

add preferences slash command #127

Closed
wants to merge 9 commits into from
Closed

add preferences slash command #127

wants to merge 9 commits into from

Conversation

darkLord19
Copy link

@mattermod
Copy link
Contributor

Hello @darkLord19,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

@codecov-io
Copy link

codecov-io commented Nov 5, 2020

Codecov Report

Merging #127 (bace31e) into master (03d549c) will increase coverage by 0.20%.
The diff coverage is 19.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #127      +/-   ##
==========================================
+ Coverage   16.60%   16.80%   +0.20%     
==========================================
  Files          15       15              
  Lines        1331     1416      +85     
==========================================
+ Hits          221      238      +17     
- Misses       1069     1136      +67     
- Partials       41       42       +1     
Impacted Files Coverage Δ
server/command_hooks.go 16.80% <19.76%> (+0.52%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03d549c...bace31e. Read the comment docs.

@hanzei hanzei requested a review from jfrerich November 5, 2020 17:54
@hanzei hanzei added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Nov 5, 2020
Copy link
Contributor

@jfrerich jfrerich left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I have some change requests that I'd like to see addressed before merging!

server/README.md Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
@jfrerich jfrerich self-requested a review November 10, 2020 21:50
Copy link
Contributor

@jfrerich jfrerich left a comment

Choose a reason for hiding this comment

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

changes requested

darkLord19 and others added 3 commits November 11, 2020 17:34
Co-authored-by: Jason Frerich <jason.frerich@mattermost.com>
Copy link
Contributor

@jfrerich jfrerich left a comment

Choose a reason for hiding this comment

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

@darkLord19, thanks for the quick turn around! There is a listing error that needs to be fixed. You can run make check-style to confirm see any errors and confirm the fix.

server/command_hooks.go Outdated Show resolved Hide resolved
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

Thanks for jumping on this issue 👍

A few comments below

server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
return &model.CommandResponse{}
}
for _, p := range prefs {
if p.Name == name {
Copy link
Contributor

@hanzei hanzei Nov 18, 2020

Choose a reason for hiding this comment

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

From looking at the content of prefs it doesn't seem like we can easily match on Name:

{
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "tutorial_step", Name: "iqbqga6mdjfa3prh59er8fh57c", Value: "999"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_approximate_view_time", Name: "", Value: "1605693815487"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_open_time", Name: "m93njr5obbyqirzf6raixu63hw", Value: "1604692117885"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "direct_channel_show", Name: "edi3ewpbcpru5gftmpxrhna31o", Value: "true"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_approximate_view_time", Name: "xnu1rgdpiffwjfb15sgdnhuaho", Value: "1604314238495"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "theme", Name: "", Value: "{\"awayIndicator\":\"#ffbc42\",\"buttonBg\":\"#166de0\",\"buttonColor\":\"#ffffff\",\"centerChannelBg\":\"#ffffff\",\"centerChannelColor\":\"#3d3c40\",\"codeTheme\":\"github\",\"dndIndicator\":\"#f74343\",\"errorTextColor\":\"#fd5960\",\"image\":\"/static/files/460473bcf310d651a1d68e35e484df97.png\",\"linkColor\":\"#2389d7\",\"mentionBg\":\"#ffffff\",\"mentionColor\":\"#145dbf\",\"mentionHighlightBg\":\"#ffe577\",\"mentionHighlightLink\":\"#166de0\",\"newMessageSeparator\":\"#ff8800\",\"onlineIndicator\":\"#06d6a0\",\"sidebarBg\":\"#145dbf\",\"sidebarHeaderBg\":\"#1153ab\",\"sidebarHeaderTextColor\":\"#ffffff\",\"sidebarText\":\"#ffffff\",\"sidebarTextActiveBorder\":\"#579eff\",\"sidebarTextActiveColor\":\"#ffffff\",\"sidebarTextHoverBg\":\"#4578bf\",\"sidebarUnreadText\":\"#ffffff\",\"type\":\"Mattermost\"}"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "direct_channel_show", Name: "h7qmwf3d7tb9mqtwzpa7njgapr", Value: "true"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_open_time", Name: "uxhczcwh3pfytj9dh5fu6bhp1h", Value: "1604575010094"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "recommended_next_steps", Name: "skip", Value: "true"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "direct_channel_show", Name: "iqbqga6mdjfa3prh59er8fh57c", Value: "true"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_open_time", Name: "umwssh8uy7fcdxoghsgwcst9we", Value: "1604496816318"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_approximate_view_time", Name: "son1npofqidwxjkodkrjbb44ua", Value: "1604400840350"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "direct_channel_show", Name: "g64gf5qtk7dp7cnxcy1p8k9g4o", Value: "true"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_open_time", Name: "kjkbt4z8kfbuuyt7h1qmy7ebuy", Value: "1604056605335"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_open_time", Name: "1i9xpftodjbn3mspx3zgnjj6gc", Value: "1604918656936"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "direct_channel_show", Name: "8se64adhfb8kdkbc9up6rqi5cc", Value: "true"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_open_time", Name: "rf76s354mbg73mhsjpcnikzyew", Value: "1604563673011"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "direct_channel_show", Name: "i35936p3cty7jyys88jidycmfh", Value: "true"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "channel_open_time", Name: "pmpc15r9f3yh5pk6ad4t9bwpsw", Value: "1604496817135"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "recommended_next_steps", Name: "hide", Value: "true"},
    model.Preference{UserId: "iqbqga6mdjfa3prh59er8fh57c", Category: "direct_channel_show", Name: "5k91qhwi9fbixq77cknfm3ywia", Value: "true"}
}

Could you please investigate if there is a way to map the preference to a human readable text?

Copy link
Author

Choose a reason for hiding this comment

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

I think category could be the actual name for preference because Name is just a UUID. Need to see how it is set across the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

@hmhealey Maybe you can help here. Do you know what kann be used as a human readable text to set/get specific preferences?

Copy link
Member

@hmhealey hmhealey Nov 23, 2020

Choose a reason for hiding this comment

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

The category/name are both arbitrary strings, so some are human readable while others aren't. For ones with the category direct_channel_show, the name is the user ID if the other user in the DM, but for ones with the category sidebar_settings, the name will be something readable like show_unread_section.

Preferences is basically a key/value store where the key is made up of the combination of category and name, so you'd want both the category and name to address a preference, but the category also lets us group related preferences in the case where you want something like all DMs with visible channels in the sidebar.

server/command_hooks.go Outdated Show resolved Hide resolved
return &model.CommandResponse{}
}
for _, p := range prefs {
if p.Name == name {
Copy link
Contributor

Choose a reason for hiding this comment

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

@hmhealey Maybe you can help here. Do you know what kann be used as a human readable text to set/get specific preferences?

server/command_hooks.go Outdated Show resolved Hide resolved
server/command_hooks.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jfrerich jfrerich left a comment

Choose a reason for hiding this comment

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

LGTM regarding my PR change requests. Approving my end, but will need to address the remaining requests from Ben and Harrison

@mattermod
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

/cc @jasonblais @jfrerich @emilyacook

@hmhealey
Copy link
Member

hmhealey commented Dec 7, 2020

@hanzei Perhaps what we could do is change the command to be like /preferences get <category> <name> so the user can specify both? We could even extend it to allow printing all preferences of a single category as well, but that's not necessary as a demo.

@hanzei
Copy link
Contributor

hanzei commented Dec 14, 2020

@hmhealey In that case, how would a user remember the name if it's an UUID ?

@hmhealey
Copy link
Member

Some preferences still have human-readable names like the sidebar_settings category has preferences named things like close_unused_direct_messages and show_unread_section. Since this is a demo plugin, I think it's fine if the user is required to use UUIDs for some things though since I assume this is mostly intended to show how the preferences part of the plugin API works.

@hanzei
Copy link
Contributor

hanzei commented Dec 15, 2020

Good point. @darkLord19 What do you think?

@darkLord19
Copy link
Author

@hanzei makes sense. I will have a go at implementing it once I have some free time on my hands.

@hanzei hanzei added the Awaiting Submitter Action Blocked on the author label Jan 15, 2021
@lindy65
Copy link

lindy65 commented May 27, 2021

Hi @darkLord19 - I'm helping to review stale PRs and am wondering whether you're able to prioritize this? Is there anything our devs can help with to push this over the finish line?

@hanzei hanzei added Lifecycle/3:orphaned and removed 2: Dev Review Requires review by a core committer Awaiting Submitter Action Blocked on the author Lifecycle/1:stale 3: QA Review Requires review by a QA tester labels Mar 9, 2023
@hanzei
Copy link
Contributor

hanzei commented Mar 9, 2023

Closing as stale. @darkLord19 Thank you very much for working on the issue.

@hanzei hanzei closed this Mar 9, 2023
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 19.76% and project coverage change: +0.20 🎉

Comparison is base (03d549c) 16.60% compared to head (bace31e) 16.80%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #127      +/-   ##
==========================================
+ Coverage   16.60%   16.80%   +0.20%     
==========================================
  Files          15       15              
  Lines        1331     1416      +85     
==========================================
+ Hits          221      238      +17     
- Misses       1069     1136      +67     
- Partials       41       42       +1     
Impacted Files Coverage Δ
server/command_hooks.go 16.80% <19.76%> (+0.52%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Demo (Get|Update|Delete)PreferencesForUser in demo plugin
8 participants