This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork20
refactor(delivery): redesign && rewrite#404
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
54 commits Select commitHold shift + click to select a range
6f181bb
refactor(delivery): back up mentions and notification
mydearxym52166a7
refactor(delivery): back up mentions and notification
mydearxym49ab9da
refactor(delivery): back up mentions and notification wip
mydearxym149f07d
refactor(delivery): wip
mydearxymf94774e
refactor(delivery): wip
mydearxyme16d5d0
refactor(delivery): wip
mydearxym6db40a3
refactor(delivery): wip
mydearxym9b6d0d6
refactor(delivery): wip
mydearxym88a4215
refactor(delivery): re-org mention & dir, naming
mydearxyme7e18c3
refactor(delivery): move cite ORM opt to delegate & fmt, naming
mydearxymdb08ad8
refactor(delivery): fix dup case
mydearxymc0883b6
refactor(delivery): wip
mydearxym05f5e6f
refactor(delivery): mention wip
mydearxym509c717
refactor(delivery): cite fix
mydearxym4dd027d
refactor(delivery): more test on mention
mydearxym3858123
refactor(delivery): better naming
mydearxyme4a2fcb
refactor(delivery): better naming
mydearxymae217bf
refactor(delivery): mini improve
mydearxym54272ba
refactor(delivery): rename fetch instead of paged_mention
mydearxym5e41de0
refactor(delivery): notification wip
mydearxym79f10f0
refactor(delivery): notification wip
mydearxyma033968
refactor(delivery): notification wip
mydearxym59adb5e
refactor(delivery): notification wip, cool
mydearxym2fb8209
refactor(delivery): use common atom key
mydearxymf253a88
refactor(delivery): upvote hooks
mydearxym28c0ee2
refactor(delivery): upvote hooks for job & blog tests
mydearxymb657180
refactor(delivery): collect hooks & tests
mydearxym60bef5a
refactor(delivery): rename type -> thread in notification
mydearxym52e13bc
refactor(delivery): fix test
mydearxym7f1332b
refactor(delivery): fix test
mydearxym0733508
refactor(delivery): enhence test
mydearxym69f37b6
refactor(cite): naming adjust
mydearxymac43691
refactor(mention): rename type -> thread
mydearxym076ad21
refactor(mention): clean up
mydearxym6d20bc5
refactor(mention): mention thread clean up
mydearxymfd59e16
refactor(mention): fix test
mydearxym25cb482
refactor(mention): fix test
mydearxym4c874e1
refactor(notify): test for follow
mydearxym7e99c6c
refactor(notify): hooks for follow & test
mydearxymdfba75e
refactor(notify): wip
mydearxym46c27fc
refactor(notify): mark read & re-org ORM functions
mydearxym7165d64
refactor(notify): clean up
mydearxym6fd1118
refactor(notify): remove old delivery system
mydearxym43d3315
refactor(notify): remove mention parse when create article
mydearxymaa80d1a
refactor(notify): refactor account mailbox tests
mydearxym61fcd0e
refactor(notify): fix notify update
mydearxym2cfc57e
refactor(mailbox): mark read test & re-org
mydearxym2136175
refactor(mailbox): remove old account mails tables
mydearxym8803436
refactor(mailbox): read_all test
mydearxym834391f
refactor(mailbox): paged mentions & test
mydearxym28ecfe5
refactor(mailbox): paged notification & test
mydearxym9954878
refactor(mailbox): read in filter
mydearxymc85886f
refactor(mailbox): clean up wip
mydearxym1bf1976
refactor(mailbox): fix tests
mydearxymFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 5 additions & 1 deletionconfig/config.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
17 changes: 6 additions & 11 deletionslib/groupher_server/accounts/accounts.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
35 changes: 21 additions & 14 deletionslib/groupher_server/accounts/delegates/fans.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletionslib/groupher_server/accounts/delegates/hooks/notify.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule GroupherServer.Accounts.Delegate.Hooks.Notify do | ||
@moduledoc """ | ||
notify hooks, for upvote, collect, comment, reply | ||
""" | ||
alias GroupherServer.{Accounts, Delivery} | ||
alias Accounts.Model.User | ||
# 发布评论是特殊情况,单独处理 | ||
def handle(:follow, %User{} = user, %User{} = from_user) do | ||
notify_attrs = %{ | ||
action: :follow, | ||
user_id: user.id | ||
} | ||
Delivery.send(:notify, notify_attrs, from_user) | ||
end | ||
def handle(:undo, :follow, %User{} = user, %User{} = from_user) do | ||
notify_attrs = %{ | ||
action: :follow, | ||
user_id: user.id | ||
} | ||
Delivery.revoke(:notify, notify_attrs, from_user) | ||
end | ||
end |
44 changes: 44 additions & 0 deletionslib/groupher_server/accounts/delegates/mailbox.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
defmodule GroupherServer.Accounts.Delegate.Mailbox do | ||
import Ecto.Query, warn: false | ||
import Helper.Utils, only: [done: 1] | ||
alias GroupherServer.{Accounts, Delivery} | ||
alias Accounts.Model.{Embeds, User} | ||
alias Helper.ORM | ||
@default_mailbox_status Embeds.UserMailbox.default_status() | ||
def mailbox_status(%User{mailbox: nil}), do: @default_mailbox_status |> done | ||
def mailbox_status(%User{mailbox: mailbox}), do: mailbox |> done | ||
def mark_read(type, ids, %User{} = user) do | ||
Delivery.mark_read(type, ids, user) | ||
end | ||
def mark_read_all(type, %User{} = user), do: Delivery.mark_read_all(type, user) | ||
def paged_mailbox_messages(type, user, filter) do | ||
Delivery.fetch(type, user, filter) | ||
end | ||
@doc "update messages count in mailbox" | ||
def update_mailbox_status(user_id) do | ||
with {:ok, user} <- ORM.find(User, user_id), | ||
{:ok, unread_mentions_count} <- Delivery.unread_count(:mention, user_id), | ||
{:ok, unread_notifications_count} <- Delivery.unread_count(:notification, user_id) do | ||
unread_total_count = unread_mentions_count + unread_notifications_count | ||
is_empty = unread_total_count < 1 | ||
mailbox = %{ | ||
unread_mentions_count: unread_mentions_count, | ||
unread_notifications_count: unread_notifications_count, | ||
unread_total_count: unread_total_count, | ||
is_empty: is_empty | ||
} | ||
user |> ORM.update_embed(:mailbox, mailbox) | ||
end | ||
end | ||
end |
130 changes: 0 additions & 130 deletionslib/groupher_server/accounts/delegates/mails.ex
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
3 changes: 1 addition & 2 deletionslib/groupher_server/accounts/delegates/profile.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletionslib/groupher_server/accounts/models/embeds/user_mailbox.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
defmodule GroupherServer.Accounts.Model.Embeds.UserMailbox do | ||
@moduledoc """ | ||
general article meta info for articles | ||
""" | ||
use Ecto.Schema | ||
use Accessible | ||
import Ecto.Changeset | ||
@optional_fields ~w(is_empty unread_total_count unread_mentions_count unread_notifications_count)a | ||
def default_status() do | ||
%{ | ||
is_empty: true, | ||
unread_total_count: 0, | ||
unread_mentions_count: 0, | ||
unread_notifications_count: 0 | ||
} | ||
end | ||
embedded_schema do | ||
field(:is_empty, :boolean, default: true) | ||
field(:unread_total_count, :integer, default: 0) | ||
field(:unread_mentions_count, :integer, default: 0) | ||
field(:unread_notifications_count, :integer, default: 0) | ||
end | ||
def changeset(struct, params) do | ||
struct |> cast(params, @optional_fields) | ||
end | ||
end |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.