mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-21 11:27:43 +00:00
[render skip] set last message id on api properly
This commit is contained in:
parent
5eabaebf45
commit
fc449fd7cf
2 changed files with 5 additions and 2 deletions
|
@ -177,7 +177,7 @@ func (a *api) upsertAccountsHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// Set account ID from Reddit
|
||||
acc.AccountID = me.ID
|
||||
|
||||
mi, err := rac.MessageInbox(ctx)
|
||||
mi, err := rac.MessageInbox(ctx, reddit.WithQuery("limit", "1"))
|
||||
if err != nil {
|
||||
a.errorResponse(w, r, 500, err)
|
||||
return
|
||||
|
@ -185,6 +185,7 @@ func (a *api) upsertAccountsHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if mi.Count > 0 {
|
||||
acc.LastMessageID = mi.Children[0].FullName()
|
||||
acc.CheckCount = 1
|
||||
}
|
||||
|
||||
if err := a.accountRepo.CreateOrUpdate(ctx, &acc); err != nil {
|
||||
|
@ -252,7 +253,7 @@ func (a *api) upsertAccountHandler(w http.ResponseWriter, r *http.Request) {
|
|||
// Set account ID from Reddit
|
||||
acct.AccountID = me.ID
|
||||
|
||||
mi, err := rac.MessageInbox(ctx)
|
||||
mi, err := rac.MessageInbox(ctx, reddit.WithQuery("limit", "1"))
|
||||
if err != nil {
|
||||
a.errorResponse(w, r, 500, err)
|
||||
return
|
||||
|
@ -260,6 +261,7 @@ func (a *api) upsertAccountHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if mi.Count > 0 {
|
||||
acct.LastMessageID = mi.Children[0].FullName()
|
||||
acct.CheckCount = 1
|
||||
}
|
||||
|
||||
// Associate
|
||||
|
|
|
@ -103,6 +103,7 @@ func (p *postgresAccountRepository) CreateOrUpdate(ctx context.Context, acc *dom
|
|||
UPDATE SET access_token = $3,
|
||||
refresh_token = $4,
|
||||
token_expires_at = $5,
|
||||
last_message_id = $6,
|
||||
is_deleted = FALSE
|
||||
RETURNING id`
|
||||
|
||||
|
|
Loading…
Reference in a new issue