Skip to content

Instantly share code, notes, and snippets.

@allenluce
Created June 11, 2015 19:09
Show Gist options
  • Save allenluce/a610c25d9c7d5433f862 to your computer and use it in GitHub Desktop.
Save allenluce/a610c25d9c7d5433f862 to your computer and use it in GitHub Desktop.
diff --git a/lyfe-mobile/openx_proto/openx_proto.pb.go b/lyfe-mobile/openx_proto/openx_proto.pb.go
index 2f2f102..e6db8cf 100644
--- a/lyfe-mobile/openx_proto/openx_proto.pb.go
+++ b/lyfe-mobile/openx_proto/openx_proto.pb.go
@@ -631,6 +631,44 @@ func (m *User) GetExt() []*ExtKeyValue {
return nil
}
+type App struct {
+ id *string `protobuf:"bytes,1,opt,name=idb" json:"id,omitempty"`
+ name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
+ bundle *string `protobuf:"bytes,3,opt,name=bundle" json:"bundle,omitempty"`
+}
+
+func (m *App) Reset() { *m = App{} }
+func (m *App) String() string { return proto.CompactTextString(m) }
+func (*App) ProtoMessage() {}
+
+func (m *App) GetAppId() string {
+ if m != nil && m.id != nil {
+ return *m.id
+ }
+ if m != nil && m.name != nil {
+ return *m.name
+ }
+ if m != nil && m.bundle != nil {
+ return *m.bundle
+ }
+ return ""
+}
+
+func (m *App) GetName() string {
+ if m != nil && m.name != nil {
+ return *m.name
+ }
+ return ""
+}
+
+func (m *App) GetBundle() string {
+ if m != nil && m.bundle != nil {
+ return *m.bundle
+ }
+ return ""
+}
+
+
type ThirdPartyKeyValue struct {
Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
Value *string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
@@ -721,6 +759,7 @@ type BidRequest struct {
ImplementationType *string `protobuf:"bytes,32,opt,name=implementation_type" json:"implementation_type,omitempty"`
SslEnabled *bool `protobuf:"varint,33,opt,name=ssl_enabled" json:"ssl_enabled,omitempty"`
User *User `protobuf:"bytes,34,opt,name=user" json:"user,omitempty"`
+ App *App `protobuf:"bytes,37,opt,name=app" json:"app,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
@@ -966,6 +1005,14 @@ func (m *BidRequest) GetUser() *User {
return nil
}
+func (m *BidRequest) GetBidApp() *App {
+ if m != nil {
+ return m.App
+ }
+ return nil
+}
+
+
type BidResponse struct {
// OPENX identifiers
ApiVersion *int32 `protobuf:"varint,1,req,name=api_version" json:"api_version,omitempty"`
diff --git a/lyfe-mobile/parsers/common.go b/lyfe-mobile/parsers/common.go
index d5cf794..73052dc 100644
--- a/lyfe-mobile/parsers/common.go
+++ b/lyfe-mobile/parsers/common.go
@@ -216,3 +216,16 @@ func CreateLyfeID(ip, ua string) string {
io.WriteString(h, combo)
return hex.EncodeToString(h.Sum(nil))
}
+
+// Return the URL if it's a recognized app store
+// Otherwise return a blank string.
+
+func OnlyStoreURL(url string) string {
+ if (strings.Index(url, "http://play.google.com/") == 0 ||
+ strings.Index(url, "http://itunes.apple.com/") == 0 ||
+ strings.Index(url, "https://play.google.com/") == 0 ||
+ strings.Index(url, "https://itunes.apple.com/") == 0) {
+ return url
+ }
+ return ""
+}
diff --git a/lyfe-mobile/parsers/openrtb.go b/lyfe-mobile/parsers/openrtb.go
index 31bf687..f32c169 100644
--- a/lyfe-mobile/parsers/openrtb.go
+++ b/lyfe-mobile/parsers/openrtb.go
@@ -55,6 +55,7 @@ type OpenrtbApp struct {
Id string
Cat []string
Keywords string
+ StoreUrl string
}
type OpenrtbUser struct {
diff --git a/lyfe-mobile/parsers/openrtb2.go b/lyfe-mobile/parsers/openrtb2.go
index 88f8cec..78a5e24 100644
--- a/lyfe-mobile/parsers/openrtb2.go
+++ b/lyfe-mobile/parsers/openrtb2.go
@@ -754,3 +754,11 @@ func (o *Openrtb2) IsInstl() bool {
return o.Impression[0].Instl == 1
}
}
+
+func (o *Openrtb2) GetStoreUrl() (string) {
+ if o.IsApp() {
+ url := o.App.StoreUrl
+ return OnlyStoreURL(url)
+ }
+ return ""
+}
diff --git a/lyfe-mobile/parsers/openx.go b/lyfe-mobile/parsers/openx.go
index ccfc8ef..6ea5c24 100644
--- a/lyfe-mobile/parsers/openx.go
+++ b/lyfe-mobile/parsers/openx.go
@@ -324,3 +324,7 @@ func (o *Openx) SetGeoPoint(lat float64, lon float64) {
func (o *Openx) NativeRubiconID() (int, error) {
return 0, new(RubiconNativeNotFound)
}
+
+func (o *Openx) GetStoreUrl() (string) {
+ return OnlyStoreURL(o.GetUrl())
+}
diff --git a/lyfe-mobile/parsers/parser_interface.go b/lyfe-mobile/parsers/parser_interface.go
index 0a6137d..08b4028 100644
--- a/lyfe-mobile/parsers/parser_interface.go
+++ b/lyfe-mobile/parsers/parser_interface.go
@@ -106,4 +106,6 @@ type Parser interface {
Duration() int
// Returns Native Rubicon asset ID
NativeRubiconID() (int, error)
+ // Returns the app/play store URL, constructed if need be.
+ GetStoreUrl() (string)
}
diff --git a/lyfe-mobile/parsers/vungle.go b/lyfe-mobile/parsers/vungle.go
index 5a6212f..8ad3855 100644
--- a/lyfe-mobile/parsers/vungle.go
+++ b/lyfe-mobile/parsers/vungle.go
@@ -278,4 +278,8 @@ func (o *Vungle) SetGeoPoint(newlat, newLon float64) {
func (o *Vungle) NativeRubiconID() (int, error) {
return 0, new(RubiconNativeNotFound)
-}
\ No newline at end of file
+}
+
+func (o *Vungle) GetStoreUrl() (string) {
+ return o.App.StoreURL
+}
diff --git a/lyfe-mobile/responders/common.go b/lyfe-mobile/responders/common.go
index f171eab..32c2e16 100644
--- a/lyfe-mobile/responders/common.go
+++ b/lyfe-mobile/responders/common.go
@@ -227,6 +227,9 @@ func FillMacros(markup []byte, req parsers.Parser, encoded_id string, cpgn campa
markup = bytes.Replace(markup, []byte("!!!third_click_unesc!!!"), []byte(filledTPClick), -1)
markup = bytes.Replace(markup, []byte("!!!third_click_esc!!!"), []byte(url.QueryEscape(filledTPClick)), -1)
+ storeUrl := req.GetStoreUrl()
+ markup = bytes.Replace(markup, []byte("!!!app_store_url!!!"), []byte(storeUrl), -1)
+
} else {
uuid, uuid_type := req.GetUserID()
if uuid != "" {
@@ -359,6 +362,9 @@ func FillMacros(markup []byte, req parsers.Parser, encoded_id string, cpgn campa
markup = bytes.Replace(markup, []byte("{third_click_unesc}"), []byte(filledTPClick), -1)
markup = bytes.Replace(markup, []byte("{third_click_esc}"), []byte(url.QueryEscape(filledTPClick)), -1)
+ storeUrl := req.GetStoreUrl()
+ markup = bytes.Replace(markup, []byte("{app_store_url}"), []byte(storeUrl), -1)
+
}
return markup, nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment