alfred-slack icon indicating copy to clipboard operation
alfred-slack copied to clipboard

No results for users and status

Open moookino opened this issue 8 years ago • 11 comments

Hi, got no users displayed when calling 'slu' option Version:1.0.0 Log for users: [2017-04-26 19:57:30][STDERR: input.scriptfilter] [alfred] 2017/04/26 19:57:30 Alfred version: 3.3.2 [redmine] 2017/04/26 19:57:30 Args: []string{"./alfred-slack", "", "{\"keyword\":\"users\"}"} [redmine] 2017/04/26 19:57:30 Using config file /Users/murat/Library/Application Support/Alfred 3/Workflow Data/com.jason0x43.alfred-slack/config.json [redmine] 2017/04/26 19:57:30 Using cache file /Users/murat/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.jason0x43.alfred-slack/cache.json [redmine] 2017/04/26 19:57:30 Using emoji dir /Users/murat/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.jason0x43.alfred-slack/emoji [redmine] 2017/04/26 19:57:30 loaded config: {token} [redmine] 2017/04/26 19:57:30 loaded cache [alfred] 2017/04/26 19:57:30 set keyword to 'users' [alfred] 2017/04/26 19:57:30 tell: data=alfred.workflowData{Keyword:"users", Mode:"tell", Mod:"", Data:""}, arg='' [alfred] 2017/04/26 19:57:30 Skipping disabled command 'token' [alfred] 2017/04/26 19:57:30 Adding items for 'users' [alfred] 2017/04/26 19:57:30 loaded cache

moookino avatar Apr 26 '17 18:04 moookino

Check the cache file in /Users/<you>/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.jason0x43.alfred-slack/cache.sjon. If it has data, the workflow is least connecting properly to Slack.

If slack doesn't actually say "No results found", it's probably downloading emoji. When you open a user list, the workflow will download the status icon for every user. If there are a lot of users with statuses, this could take a little while (it shouldn't be more than a minute unless there are quite a few users). Emoji are cached locally, so this should only happen once.

jason0x43 avatar May 04 '17 12:05 jason0x43

Hi @jason0x43 thx for your answer, looked at this folder and cache file is present

But, folder emoji after workflow reset still has no emojis and in cache file has "Users": null, value

Then status not shown to

`[2017-05-04 15:48:38][ERROR: input.scriptfilter] Code 2: [alfred] 2017/05/04 15:48:36 Alfred version: 3.3.2 [redmine] 2017/05/04 15:48:36 Args: []string{"./alfred-slack", "", "{"keyword":"status"}"} [redmine] 2017/05/04 15:48:36 Using config file /Users/user/Library/Application Support/Alfred 3/Workflow Data/com.jason0x43.alfred-slack/config.json [redmine] 2017/05/04 15:48:36 Using cache file /Users/user/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.jason0x43.alfred-slack/cache.json [redmine] 2017/05/04 15:48:36 Using emoji dir /Users/user/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.jason0x43.alfred-slack/emoji [redmine] 2017/05/04 15:48:36 loaded config: {token} [redmine] 2017/05/04 15:48:36 loaded cache [alfred] 2017/05/04 15:48:36 set keyword to 'status' [alfred] 2017/05/04 15:48:36 tell: data=alfred.workflowData{Keyword:"status", Mode:"tell", Mod:"", Data:""}, arg='' [alfred] 2017/05/04 15:48:36 Skipping disabled command 'token' [alfred] 2017/05/04 15:48:36 Adding items for 'status' [redmine] 2017/05/04 15:48:36 GETing from URL: https://api.slack.com/api/users.getPresence?token=token&user=user panic: runtime error: index out of range

goroutine 1 [running]: main.StatusCommand.Items(0x7fff5fbff9e7, 0x0, 0x0, 0x0, 0xc420139980, 0x19, 0x0, 0x0, 0x19) /Users/jason/Documents/Programming/go/src/github.com/jason0x43/alfred-slack/status.go:134 +0x2702 main.(*StatusCommand).Items(0x15be640, 0x7fff5fbff9e7, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0xe786) :13 +0x6d github.com/jason0x43/go-alfred.(*Workflow).Run(0x15a2100, 0xc420165e88, 0x5, 0x5) /Users/jason/Documents/Programming/go/src/github.com/jason0x43/go-alfred/workflow.go:258 +0x5e6 main.main() /Users/jason/Documents/Programming/go/src/github.com/jason0x43/alfred-slack/main.go:84 +0xa84`

Could it be because of custom emojis used by team users?

moookino avatar May 04 '17 13:05 moookino

Custom emoji's shouldn't be a problem. However, the lack of user data in your cache file certainly is.

Try this: In your cache file, remove the line starting with "Time":. Open up the workflow debug window and then run slu. You should see something like this:

[alfred] 2017/05/04 09:59:02 Adding items for 'users'
[redmine] 2017/05/04 09:59:02 Refreshing cache...
[redmine] 2017/05/04 09:59:02 GETing from URL: https://api.slack.com/api/emoji.list?token={token}
[redmine] 2017/05/04 09:59:02 GETing from URL: https://api.slack.com/api/auth.test?token={token}
[redmine] 2017/05/04 09:59:02 GETing from URL: https://api.slack.com/api/channels.list?exclude_archived=1&token={token}
[redmine] 2017/05/04 09:59:02 GETing from URL: https://api.slack.com/api/users.list?token={token}
[redmine] 2017/05/04 09:59:02 Got users
[redmine] 2017/05/04 09:59:02 Got emoji
[redmine] 2017/05/04 09:59:02 Got auth
[redmine] 2017/05/04 09:59:02 GETing from URL: https://api.slack.com/api/users.getPresence?token={token}&user={user1}
[redmine] 2017/05/04 09:59:02 GETing from URL: https://api.slack.com/api/users.getPresence?token={token}&user={user2}
...
[redmine] 2017/05/04 09:59:03 Got presence for {user1}
[redmine] 2017/05/04 09:59:03 Got presence for {user2}
...

jason0x43 avatar May 04 '17 14:05 jason0x43

On first time not worked, but after with to all information in debug mode finally worked 🤔 Thx for help, now it works as expected

moookino avatar May 04 '17 14:05 moookino

Weird. Glad to hear it's working now. I'll have to look into that more, though; maybe it's something that just happens during initial setup.

jason0x43 avatar May 04 '17 15:05 jason0x43

FWIW I'm seeing a similar issue.

When I try to see or set my status I see this in the debug log:

[slack] 2017/05/06 14:12:43 GETing from URL: https://api.slack.com/api/users.getPresence?token=xxx&user=
panic: runtime error: index out of range

goroutine 1 [running]:
main.StatusCommand.Items(0x7fff5fbff99f, 0x0, 0x0, 0x0, 0xc4200d67a0, 0x19, 0x0, 0x0, 0x19)
	/Users/jason/Documents/Programming/go/src/github.com/jason0x43/alfred-slack/status.go:134 +0x26fa
main.(*StatusCommand).Items(0x15be640, 0x7fff5fbff99f, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x3, 0x6)
	<autogenerated>:13 +0x6d
github.com/jason0x43/go-alfred.(*Workflow).Run(0x15a2100, 0xc420105e88, 0x5, 0x5)
	/Users/jason/Documents/Programming/go/src/github.com/jason0x43/go-alfred/workflow.go:258 +0x5e6
main.main()
	/Users/jason/Documents/Programming/go/src/github.com/jason0x43/alfred-slack/main.go:83 +0xa84

danieljimenez avatar May 06 '17 19:05 danieljimenez

@danieljimenez have u tryed to remove time string from cache.json multiple times and rerun workflow for caching again?

moookino avatar May 07 '17 01:05 moookino

The panic is happening because the workflow is trying to read presence data from the cache when the cache is empty. I must have missed a check somewhere; I'll look into it.

jason0x43 avatar May 07 '17 13:05 jason0x43

It also turns out I had refreshed my token one too many times, and was using an invalid one (but still seeing a channel list, cache maybe?)

On May 7, 2017, at 8:23 AM, Jason Cheatham [email protected] wrote:

The panic is happening because the workflow is trying to read presence data from the cache when the cache is empty. I must have missed a check somewhere; I'll look into it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

danieljimenez avatar May 07 '17 13:05 danieljimenez

Yeah. Apparently the cache handling could be a bit smarter.

jason0x43 avatar May 07 '17 13:05 jason0x43

Yeah, I think the specific issue is that if sls is called before anything else, it will end up trying to lookup up a user in an empty cache. The sls command should invoke the cache refresh logic just like the other commands.

jason0x43 avatar May 19 '17 20:05 jason0x43