I am using this gem for private messages: https://github.com/jongilbraith/simple-private-messages
I want to create a thread conversation instead of the e-mail conversation the scaffold have provided.
Example, User A have sent 10 messages to User B. User A have also sent 10 messages to User C.
Instead of looping through all the messages. (e-mail look) I want to create a threat like:
Inbox
Conversation with User A (10 messages)
Conversation with User C (10 messages)
And when clicking on the conversation the messages should be ordered after date. So it would be like a conversation.
The table for messages:
id
sender_id
recipient_id
sender_deleted
recipient_deleted
subject
body
read_at
created_at
updated_at
How do I create these views? How do I group the messages?
Short answer is: you can't with that gem. You'll have to extend it and add a Conversation model then bridge that between users and messages.
I propose, instead, you use this gem:
https://github.com/ging/mailboxer
Far more powerful than your current gem, and it comes with conversations out of the box. I've used it before to mimic a gmail-like view.
From the guide:
#alfa wants to retrieve all his conversations
alfa.mailbox.conversations
#A wants to retrieve his inbox
alfa.mailbox.inbox
#A wants to retrieve his sent conversations
alfa.mailbox.sentbox
#alfa wants to retrieve his trashed conversations
alfa.mailbox.trash
Easy as pie:
current_user.mailbox.conversations.each do |convo|
convo.subject
...
end
Related
I want to send a message to any public channel that my bot gets added to. I notice there's the member_joined_channel event as documentated here, however I'm not sure how to figure out when to determine if my bot was the invited member. I know there's the user property, but I don't want to hardcode my bot's user ID.
I'm not familiar with the slack API, but i found this endpoint :
https://api.slack.com/types/conversation
In the response, you have a flag is_member which contains what you need I think :
is_member indicates whether the user, bot user or Slack app associated
with the token making the API call is itself a member of the
conversation.
EDIT:
then, you can retreive the list of public channel and have this flag on every channel accessible :
https://api.slack.com/methods/conversations.list
If you are writing a WebSocket-based "RTM" bot, you can listen for the channel_joined event, which is sent only for your own user/bot.
For the more typical Webhook-based bot, the best choice is to listen for the member_joined_channel event and compare the user field if you want an event-based implementation. Hardcoding or otherwise storing your bot's user id is a necessity.
Otherwise, as suggested in the previous answer, you can periodically query all conversations with the conversations.list method and check if you have become a member using the is_member field.
In case one of these methods does not provide the is_private field that you need to determine whether a channel is public, you can use the conversations.info method, which returns a channel object with the is_private field.
Coversation info is your friend https://api.slack.com/methods/conversations.info
The use case:
We are creating a system which analyses mail content. If we are able to categorize and archive an email based on its content, we want to automatically categorize subsequent emails in the same conversation / thread.
The issue is that the conversationId we get as part of the (mail)message is not unique when we query on behalf of different users.
An example:
A: The conversationId for a given thread in my inbox.
B: The conversationId for the same thread, but in a different user's inbox.
Values:
A:AAQkADUyZWYxNzljLTc4NjItNGMzYy1iZDYwLTE4NWEzNDg1OWUzZQAQABlanHOPI0v1ukA7KePaYv4=.
B:AAQkAGVkNGRjNWNmLTAwNTItNDA2NC1hOThhLTU5NTUyNGFjNTM5ZAAQABlanHOPI0v1ukA7KePaYv4=.
Can I use parts of this conversationId to identify the same conversation across different users? The pattern seems to be that the last 25-26 characters are unique for the given conversation. The rest is a Guid + a postfix of some sort.
Edit: My question is related to usage of the Microsoft Graph API. There are questions answered on SO related to ConversationIds and Outlook emails, but these describe cases getting emails direct from the outlook client (or maybe through the outlook api). For instance are properties like the ConversationIndex and ConversationTopic not in the message I get from the Graph API.
As the title says I am trying to access recipient when sending bulk mail.
Right now I am doing this, sending to participants collection with info about event, but I also want to access each participant in view.
Mail::to($this->participants)->send(new News($this->event));
I could do a foreach but I do not think that is efficient.
I need something like this, so I could get the participant in the mail class to send it to view.
Mail::to($this->participants)->send(new News($this->event, $this->participant));
I have a schema that looks something like:
Installation <user, etc>
User <id, contact info, etc>
activities <fromUser, toUser, type[follow, like, share]>
...
I want to occasionally fire off a push notification to someone's followers. I can get the follows for someone like so:
var followsQuery = new Parse.Query("activity");
followsQuery.equalTo("toUser", user.id);
followsQuery.equalTo("type", "follow");
.. and iterate through the follows and call Parse.Push.send for each of them, but I don't think this is the best way to go about doing this, and I'm worried about this timing out for people with large number of followers.
How do I form the pushQuery so as to form a join with the user and activities tables?
You can create a channel for each user called "follow_[objectId]" where [objectId] is that user's objectId. Whenever a user follows someone, add that someone's follow channel to the user's push channels. Then, whenever you want to send a push notification to someone's followers, just push to their follow channel. Their followers should be subscribed to that channel and get the push.
This can be problematic if a user follows many people. When they login, the app would have to query for all the people they follow, and subscribe to all those channels, which could take a while.
The current system features plaintext comments on pieces of content stored in a mySQL database, and I'm looking to add email notifications.
Current ideas:
Emails to each user in the thread (no matter how deep)?
Email only to the owner of the comment you are replying to?
Email to content owner for each new comment? Only root level comments?
Email only to users that check off a 'Notify me of replies' below each content piece, containing any new comment, threaded or not
Thoughts?
I'd design around the idea of notifications.
Users could pick which events they're interested in subscribing to, then indicate how they want to receive notifications by email. This way, you can accommodate users who want no notification, as well as those who want notification by email, digest email, SMS, RSS, smoke signals, carrier pigeons, and telegraph.
Ended up going with 2 settings that are changeable by the user:
Email me for any new root level comments [X] On [] Off
Email me for any new comment replies [X] On [] Off