mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +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) {
|
||||
|
||||
card, code, err := BearerContactToken(r, false)
|
||||
card, code, err := ParamContactToken(r, false)
|
||||
if err != nil {
|
||||
ErrResponse(w, code, err)
|
||||
return
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user