mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 20:49:16 +00:00
receiving remote contact notifications
This commit is contained in:
parent
1ae7544cdb
commit
221b599b08
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func SetArticleRevision(w http.ResponseWriter, r *http.Request) {
|
func SetArticleRevision(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
card, code, err := BearerContactToken(r, false)
|
card, code, err := ParamContactToken(r, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrResponse(w, code, err)
|
ErrResponse(w, code, err)
|
||||||
return
|
return
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func SetChannelRevision(w http.ResponseWriter, r *http.Request) {
|
func SetChannelRevision(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
card, code, err := BearerContactToken(r, false)
|
card, code, err := ParamContactToken(r, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrResponse(w, code, err)
|
ErrResponse(w, code, err)
|
||||||
return
|
return
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func SetProfileRevision(w http.ResponseWriter, r *http.Request) {
|
func SetProfileRevision(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
card, code, err := BearerContactToken(r, false)
|
card, code, err := ParamContactToken(r, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrResponse(w, code, err)
|
ErrResponse(w, code, err)
|
||||||
return
|
return
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func SetViewRevision(w http.ResponseWriter, r *http.Request) {
|
func SetViewRevision(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
card, code, err := BearerContactToken(r, false)
|
card, code, err := ParamContactToken(r, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrResponse(w, code, err)
|
ErrResponse(w, code, err)
|
||||||
return
|
return
|
||||||
|
@ -162,6 +162,7 @@ func BearerAppToken(r *http.Request, detail bool) (*store.Account, int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ParseToken(token string) (string, string, error) {
|
func ParseToken(token string) (string, string, error) {
|
||||||
|
|
||||||
split := strings.Split(token, ".")
|
split := strings.Split(token, ".")
|
||||||
if len(split) != 2 {
|
if len(split) != 2 {
|
||||||
return "", "", errors.New("invalid token format")
|
return "", "", errors.New("invalid token format")
|
||||||
@ -199,7 +200,7 @@ func ParamContactToken(r *http.Request, detail bool) (*store.Card, int, error) {
|
|||||||
// find token record
|
// find token record
|
||||||
var card store.Card
|
var card store.Card
|
||||||
if detail {
|
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) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
} else {
|
} else {
|
||||||
@ -207,7 +208,7 @@ func ParamContactToken(r *http.Request, detail bool) (*store.Card, int, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return nil, http.StatusNotFound, err
|
return nil, http.StatusNotFound, err
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user