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

Make "Uncategorized" channel *REAL* uncategorized #46

Closed
lgxz opened this issue Aug 11, 2021 · 13 comments
Closed

Make "Uncategorized" channel *REAL* uncategorized #46

lgxz opened this issue Aug 11, 2021 · 13 comments
Labels
wontfix This will not be worked on

Comments

@lgxz
Copy link

lgxz commented Aug 11, 2021

The so-called "Uncategorised" channel is indeed a NORMAL channel and has it's own Token.

I modified the server code to send message with uid instead of the channel token. for example,
https://test.server/v2/sender/:uid/:msg

Then the funny thing is:

  1. The message DOES pop up in the notification center.
  2. Chanify App shows the number of unread messages.
  3. You can't see the message in App because it doesn't belong to any channel.

Screenshot

@wizjin wizjin added the wontfix This will not be worked on label Aug 11, 2021
@wizjin
Copy link
Contributor

wizjin commented Aug 11, 2021

@lgxz Avoid illegal channels that have been used, so the uncategorized channel is the default channel.

If you modified the server code, you can add default channel for uid.

Thanks

@lgxz
Copy link
Author

lgxz commented Aug 11, 2021

@lgxz Avoid illegal channels that have been used, so the uncategorized channel is the default channel.

If you modified the server code, you can add default channel for uid.

Thanks

Yes. The problem is that the messages will be invisible in App completely if I sent messages without any channel information. The App only shows the number of unread messages. And, you can't get rid of the unread number from App forever.

@wizjin
Copy link
Contributor

wizjin commented Aug 11, 2021

Server will add default channel.

https://github.com/chanify/chanify/blob/e251ca1c307b6414c0978273d0b74e14706121ba/model/token.go#L64

How did you modify the code?

Thanks.

@lgxz
Copy link
Author

lgxz commented Aug 11, 2021

Server will add default channel.

https://github.com/chanify/chanify/blob/e251ca1c307b6414c0978273d0b74e14706121ba/model/token.go#L64

How did you modify the code?

Thanks.

Great. Sorry, I don't know how to paste formatted code.
It's very simple:

  1. Add s.GET("/sender/:uid/:msg", c.handleUserSender), copy handlerSender function to handerUserSender
  2. In handleUserSender, extract uid from request instead of token. And change msg to msg := &model.Message{}
  3. In handleUserSender, call c.sendUidMsg(ctx, uid, msg.SoundName(ctx.Query("sound")).SetPriority(parsePriority(ctx.Query("priority"))))
  4. Copy sendMsg to sendUidMsg, change token to uid

@lgxz
Copy link
Author

lgxz commented Aug 11, 2021

@wizjin
Copy link
Contributor

wizjin commented Aug 11, 2021

m := &Message{}
m.From = tk.GetNodeID()
m.Channel = tk.GetChannel()
m.TokenHash = tk.HashValue()

From, Channel and TokenHash must be inited, then client will work.

  • From: NodeId for decrypt message
  • Channel: Can use defaultChannel
  • TokenHash: Use for feature(token blocked list). You can use empty string "", but this way will disable token blocked list.

Thanks

@lgxz
Copy link
Author

lgxz commented Aug 11, 2021

```go
m := &Message{}
m.From = tk.GetNodeID()
m.Channel = tk.GetChannel()
m.TokenHash = tk.HashValue()

From, Channel and TokenHash must be inited, then client will work.

From: NodeId for decrypt message
Channel: Can use defaultChannel
TokenHash: Use for feature(token blocked list). You can use empty string "", but this way will disable token blocked list.

Thanks

Thanks.

The message can be displayed in iOS Notification Center correctly even without the From field.
Does the current App support default channel? I will try it.

@wizjin
Copy link
Contributor

wizjin commented Aug 11, 2021

Without the From field work, because SendAPNS will fix it. (only direct send can ignore From field)

You can add defaultChannel, then client will work.

@lgxz
Copy link
Author

lgxz commented Aug 11, 2021

Without the From field work, because SendAPNS will fix it. (only direct send can ignore From field)

You can add defaultChannel, then client will work.

Thanks.

Just tried it, same result. The messages are still invisible in App.

Edit:
Sorry, I made a mistake. I set msg.From to defaultChannel. And the message still displayed correctly in notification center!
It works after I fixed the mistake.

@wizjin
Copy link
Contributor

wizjin commented Aug 12, 2021

I suggest you to set msg.From with logic.NodeID, because the image/sound/file/long text message need msg.From.

The feature 47 will can be used to solve the empty channel.

  • if m.Channel == nil, client will set channel to defaultChannel
  • if m.Channel == invalid channel, client will ignore this channel

Thanks

@lgxz
Copy link
Author

lgxz commented Aug 12, 2021

```go
m := &Message{}
m.From = tk.GetNodeID()
m.Channel = tk.GetChannel()
m.TokenHash = tk.HashValue()

From, Channel and TokenHash must be inited, then client will work.

From: NodeId for decrypt message
Channel: Can use defaultChannel
TokenHash: Use for feature(token blocked list). You can use empty string "", but this way will disable token blocked list.

Thanks

The defaultChannel is an unnamed system channel. Messages sent to the defaultChannel will be put in the uncategorised channel by client app.

But, if you set the "Name" property of defaultChannel, this will force client app create an unnamed system channel.
And, user can't delete the new created channel.

I suggest you to set msg.From with logic.NodeID, because the image/sound/file/long text message need msg.From.

The feature 47 will can be used to solve the empty channel.

  • if m.Channel == nil, client will set channel to defaultChannel
  • if m.Channel == invalid channel, client will ignore this channel

Thanks

Thanks.

What is an "invalid channel"?
I hope that client won't ignore the unknown channels so that we can push categorized messages to many clients without knowing every channel token.

@lgxz
Copy link
Author

lgxz commented Aug 12, 2021

This is the commit to send categorised message to user directly:
https://github.com/lgxz/chanify/commit/a4f6f526d5758654bd8fa8c95515769f6ca113aa

We do not need to know the channel token of every client.

By "curl https://server/.../msg?chan=Event&code=100", the clients will create "Event" channel automatically and put message in it.

@wizjin
Copy link
Contributor

wizjin commented Aug 22, 2021

v1.2.2 release

@wizjin wizjin closed this as completed Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants