receiving remote contact notifications

This commit is contained in:
Roland Osborne 2022-06-10 00:16:19 -07:00
parent 1ae7544cdb
commit 221b599b08
5 changed files with 7 additions and 6 deletions

View File

@ -8,7 +8,7 @@ import (
func SetArticleRevision(w http.ResponseWriter, r *http.Request) {
card, code, err := BearerContactToken(r, false)
card, code, err := ParamContactToken(r, false)
if err != nil {
ErrResponse(w, code, err)
return

View File

@ -8,7 +8,7 @@ import (
func SetChannelRevision(w http.ResponseWriter, r *http.Request) {
card, code, err := BearerContactToken(r, false)
card, code, err := ParamContactToken(r, false)
if err != nil {
ErrResponse(w, code, err)
return

View File

@ -8,7 +8,7 @@ import (
func SetProfileRevision(w http.ResponseWriter, r *http.Request) {
card, code, err := BearerContactToken(r, false)
card, code, err := ParamContactToken(r, false)
if err != nil {
ErrResponse(w, code, err)
return

View File

@ -8,7 +8,7 @@ import (
func SetViewRevision(w http.ResponseWriter, r *http.Request) {
card, code, err := BearerContactToken(r, false)
card, code, err := ParamContactToken(r, false)
if err != nil {
ErrResponse(w, code, err)
return

View File

@ -162,6 +162,7 @@ func BearerAppToken(r *http.Request, detail bool) (*store.Account, int, error) {
}
func ParseToken(token string) (string, string, error) {
split := strings.Split(token, ".")
if len(split) != 2 {
return "", "", errors.New("invalid token format")
@ -199,7 +200,7 @@ func ParamContactToken(r *http.Request, detail bool) (*store.Card, int, error) {
// find token record
var card store.Card
if detail {
if err := store.DB.Preload("Account.AccountDetail").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
if err := store.DB.Preload("CardSlot").Preload("Account.AccountDetail").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, http.StatusNotFound, err
} else {
@ -207,7 +208,7 @@ func ParamContactToken(r *http.Request, detail bool) (*store.Card, int, error) {
}
}
} else {
if err := store.DB.Preload("Account").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
if err := store.DB.Preload("CardSlot").Preload("Account").Where("account_id = ? AND in_token = ?", target, access).First(&card).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, http.StatusNotFound, err
} else {