convo alerts
change convo_dev phrase change account_menu_messages phrase change alerts_no_linked_topic phrase change alerts_no_linked_topic_by_reply phrase add alerts.convo_create phrase add alerts.convo_reply phrase add alerts_no_linked_convo phrase
This commit is contained in:
parent
01b7a18ea9
commit
cd7577c84c
|
@ -100,6 +100,14 @@ func BuildAlert(alert Alert, user User /* The current user */) (out string, err
|
|||
var url, area string
|
||||
phraseName := "." + alert.ElementType
|
||||
switch alert.ElementType {
|
||||
case "convo":
|
||||
convo, err := Convos.Get(alert.ElementID)
|
||||
if err != nil {
|
||||
DebugLogf("Unable to find linked convo %d", alert.ElementID)
|
||||
return "", errors.New(phrases.GetErrorPhrase("alerts_no_linked_convo"))
|
||||
}
|
||||
url = convo.Link
|
||||
area = ""
|
||||
case "topic":
|
||||
topic, err := Topics.Get(alert.ElementID)
|
||||
if err != nil {
|
||||
|
@ -138,6 +146,8 @@ func BuildAlert(alert Alert, user User /* The current user */) (out string, err
|
|||
}
|
||||
|
||||
switch alert.Event {
|
||||
case "create":
|
||||
phraseName += "_create"
|
||||
case "like":
|
||||
phraseName += "_like"
|
||||
case "mention":
|
||||
|
@ -149,6 +159,7 @@ func BuildAlert(alert Alert, user User /* The current user */) (out string, err
|
|||
return buildAlertString(phraseName, []string{alert.Actor.Name, area}, url, alert.Actor.Avatar, alert.ASID), nil
|
||||
}
|
||||
|
||||
// TODO: Use a string builder?
|
||||
func buildAlertString(msg string, sub []string, path, avatar string, asid int) string {
|
||||
var subString string
|
||||
for _, item := range sub {
|
||||
|
|
|
@ -183,6 +183,7 @@ func NewDefaultConversationStore(acc *qgen.Accumulator) (*DefaultConversationSto
|
|||
func (s *DefaultConversationStore) Get(id int) (*Conversation, error) {
|
||||
co := &Conversation{ID: id}
|
||||
err := s.get.QueryRow(id).Scan(&co.CreatedBy, &co.CreatedAt, &co.LastReplyBy, &co.LastReplyAt)
|
||||
co.Link = BuildConvoURL(co.ID)
|
||||
return co, err
|
||||
}
|
||||
|
||||
|
@ -199,6 +200,7 @@ func (s *DefaultConversationStore) GetUser(uid, offset int) (cos []*Conversation
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
co.Link = BuildConvoURL(co.ID)
|
||||
cos = append(cos, co)
|
||||
}
|
||||
err = rows.Err()
|
||||
|
|
|
@ -111,8 +111,9 @@
|
|||
|
||||
"alerts_no_actor":"Unable to find the actor",
|
||||
"alerts_no_target_user":"Unable to find the target user",
|
||||
"alerts_no_linked_topic":"Unable to find the linked topic",
|
||||
"alerts_no_linked_topic_by_reply":"Unable to find the linked reply or parent topic",
|
||||
"alerts_no_linked_topic":"Unable to find linked topic",
|
||||
"alerts_no_linked_topic_by_reply":"Unable to find linked reply or parent topic",
|
||||
"alerts_no_linked_convo":"Unable to find linked convo",
|
||||
"alerts_invalid_elementtype":"Invalid elementType",
|
||||
|
||||
"panel_groups_need_name":"The group name can't be left blank.",
|
||||
|
@ -328,7 +329,7 @@
|
|||
"password_reset_email_sent":"An email was sent to you. Please follow the steps within.",
|
||||
"password_reset_token_token_verified":"Your password was successfully updated.",
|
||||
|
||||
"convo_dev":"Messages are currently under development. Some features may not work yet and your messages may be purged every now and then.",
|
||||
"convo_dev":"Conversations are currently under development. Some features may not work yet and your messages may be purged every now and then.",
|
||||
|
||||
"panel_forum_created":"The forum was successfully created.",
|
||||
"panel_forum_deleted":"The forum was successfully deleted.",
|
||||
|
@ -380,6 +381,9 @@
|
|||
"alerts.user_mention":"{0} mentioned you on {1}'s profile",
|
||||
"alerts.new_friend_invite":"You received a friend invite from {0}",
|
||||
|
||||
"alerts.convo_create":"{0} added you to a conversation",
|
||||
"alerts.convo_reply":"{0} replied to a conversation",
|
||||
|
||||
"alerts.no_alerts":"You don't have any alerts",
|
||||
"alerts.no_alerts_short":"No new alerts",
|
||||
|
||||
|
@ -511,7 +515,7 @@
|
|||
"account_menu_privacy":"Privacy",
|
||||
"account_menu_blocked":"Blocked",
|
||||
"account_menu_penalties":"Penalties",
|
||||
"account_menu_messages":"Messages",
|
||||
"account_menu_messages":"Conversations",
|
||||
|
||||
"account_coming_soon":"Coming Soon",
|
||||
|
||||
|
|
|
@ -210,6 +210,26 @@ func ConvosCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User) c.R
|
|||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
// TODO: Don't bother making the subscription if the convo creator is the only recipient?
|
||||
for _, uid := range rlist {
|
||||
if uid == user.ID {
|
||||
continue
|
||||
}
|
||||
err := c.Subscriptions.Add(uid, cid, "convo")
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
}
|
||||
err = c.Subscriptions.Add(user.ID, cid, "convo")
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
err = c.AddActivityAndNotifyAll(c.Alert{ActorID: user.ID, Event: "create", ElementType: "convo", ElementID: cid, Actor: &user})
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/user/convo/"+strconv.Itoa(cid), http.StatusSeeOther)
|
||||
return nil
|
||||
}
|
||||
|
@ -269,7 +289,11 @@ func ConvosCreateReplySubmit(w http.ResponseWriter, r *http.Request, user c.User
|
|||
|
||||
body := c.PreparseMessage(r.PostFormValue("content"))
|
||||
post := &c.ConversationPost{CID: cid, Body: body, CreatedBy: user.ID}
|
||||
_, err = post.Create()
|
||||
pid, err := post.Create()
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
err = c.AddActivityAndNotifyAll(c.Alert{ActorID: user.ID, Event: "reply", ElementType: "convo", ElementID: cid, Actor: &user, Extra: strconv.Itoa(pid)})
|
||||
if err != nil {
|
||||
return c.InternalError(err, w, r)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue