Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pixfuture-media/prebid-server
Browse files Browse the repository at this point in the history
  • Loading branch information
pixfuture-media committed Dec 19, 2024
2 parents a22b19e + 3f33089 commit 993f157
Show file tree
Hide file tree
Showing 55 changed files with 365 additions and 147 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/slack-stale-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Post Stale PRs To Slack

on:
# run Monday 9am and on-demand
workflow_dispatch:
schedule:
- cron: '0 9 * * 1'

jobs:
fetch-PRs:
runs-on: ubuntu-latest
steps:
- name: Fetch pull requests
id: local
uses: paritytech/[email protected]
with:
GITHUB_TOKEN: ${{ github.token }}
days-stale: 14
ignoredLabels: "blocked"
- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-message: "${{ steps.local.outputs.message }}"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
16 changes: 14 additions & 2 deletions adapters/metax/metax.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ func (a *adapter) MakeBids(bidReq *openrtb2.BidRequest, reqData *adapters.Reques
return nil, []error{err}
}
resp.Bids = append(resp.Bids, &adapters.TypedBid{
Bid: bid,
BidType: bidType,
Bid: bid,
BidType: bidType,
BidVideo: getBidVideo(bid),
})
}
}
Expand Down Expand Up @@ -177,6 +178,17 @@ func getBidType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) {
}
}

func getBidVideo(bid *openrtb2.Bid) *openrtb_ext.ExtBidPrebidVideo {
bidVideo := openrtb_ext.ExtBidPrebidVideo{}
if len(bid.Cat) > 0 {
bidVideo.PrimaryCategory = bid.Cat[0]
}
if bid.Dur > 0 {
bidVideo.Duration = int(bid.Dur)
}
return &bidVideo
}

// Builder builds a new instance of the MetaX adapter for the given bidder with the given config.
func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) {
if config.Endpoint == "" {
Expand Down
42 changes: 42 additions & 0 deletions adapters/metax/metax_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,48 @@ func TestGetBidType(t *testing.T) {
}
}

func TestGetBidVideo(t *testing.T) {
tests := []struct {
description string
bid *openrtb2.Bid
bidvideo openrtb_ext.ExtBidPrebidVideo
}{
{
description: "One category, no duration",
bid: &openrtb2.Bid{Cat: []string{"IAB1-1"}},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 0},
},
{
description: "Two categories and use the first, no duration",
bid: &openrtb2.Bid{Cat: []string{"IAB1-1", "IAB1-2"}},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 0},
},
{
description: "No category, no duration",
bid: &openrtb2.Bid{Cat: []string{}},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "", Duration: 0},
},
{
description: "No category(nil), no duration",
bid: &openrtb2.Bid{Cat: nil},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "", Duration: 0},
},
{
description: "Two categories and use the first, duration is 15",
bid: &openrtb2.Bid{Cat: []string{"IAB1-1", "IAB1-2"}, Dur: 15},
bidvideo: openrtb_ext.ExtBidPrebidVideo{PrimaryCategory: "IAB1-1", Duration: 15},
},
}

for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
bidVideo := getBidVideo(test.bid)
assert.Equal(t, test.bidvideo.PrimaryCategory, bidVideo.PrimaryCategory)
assert.Equal(t, test.bidvideo.Duration, bidVideo.Duration)
})
}
}

func TestBuilder(t *testing.T) {
serverCfg := config.Server{}

Expand Down
20 changes: 17 additions & 3 deletions adapters/metax/metaxtest/exemplary/simple-app-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@
"crid": "test-crid",
"w": 1024,
"h": 576,
"mtype": 2
"mtype": 2,
"dur": 15,
"cat": [
"IAB1-5",
"IAB1-6"
]
}
]
}
Expand All @@ -120,9 +125,18 @@
"crid": "test-crid",
"w": 1024,
"h": 576,
"mtype": 2
"mtype": 2,
"dur": 15,
"cat": [
"IAB1-5",
"IAB1-6"
]
},
"type": "video"
"type": "video",
"video": {
"duration": 15,
"primary_category": "IAB1-5"
}
}
]
}
Expand Down
2 changes: 0 additions & 2 deletions adapters/pubmatic/pubmatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ type extRequestAdServer struct {
Wrapper *pubmaticWrapperExt `json:"wrapper,omitempty"`
Acat []string `json:"acat,omitempty"`
Marketplace *marketplaceReqExt `json:"marketplace,omitempty"`
openrtb_ext.ExtRequest
}

type respExt struct {
Expand Down Expand Up @@ -362,7 +361,6 @@ func extractPubmaticExtFromRequest(request *openrtb2.BidRequest) (extRequestAdSe
if err != nil {
return pmReqExt, fmt.Errorf("error decoding Request.ext : %s", err.Error())
}
pmReqExt.ExtRequest = *reqExt

reqExtBidderParams := make(map[string]json.RawMessage)
if reqExt.Prebid.BidderParams != nil {
Expand Down
31 changes: 2 additions & 29 deletions adapters/pubmatic/pubmatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,8 @@ func TestExtractPubmaticExtFromRequest(t *testing.T) {
Ext: json.RawMessage(`{"prebid":{"bidderparams":{}}}`),
},
},
expectedReqExt: extRequestAdServer{
ExtRequest: openrtb_ext.ExtRequest{
Prebid: openrtb_ext.ExtRequestPrebid{
BidderParams: json.RawMessage("{}"),
},
},
},
wantErr: false,
expectedReqExt: extRequestAdServer{},
wantErr: false,
},
{
name: "Only_Pubmatic_wrapper_ext_present",
Expand All @@ -286,11 +280,6 @@ func TestExtractPubmaticExtFromRequest(t *testing.T) {
},
expectedReqExt: extRequestAdServer{
Wrapper: &pubmaticWrapperExt{ProfileID: 123, VersionID: 456},
ExtRequest: openrtb_ext.ExtRequest{
Prebid: openrtb_ext.ExtRequestPrebid{
BidderParams: json.RawMessage(`{"wrapper":{"profile":123,"version":456}}`),
},
},
},
wantErr: false,
},
Expand All @@ -313,11 +302,6 @@ func TestExtractPubmaticExtFromRequest(t *testing.T) {
expectedReqExt: extRequestAdServer{
Wrapper: &pubmaticWrapperExt{ProfileID: 123, VersionID: 456},
Acat: []string{"drg", "dlu", "ssr"},
ExtRequest: openrtb_ext.ExtRequest{
Prebid: openrtb_ext.ExtRequestPrebid{
BidderParams: json.RawMessage(`{"acat":[" drg \t","dlu","ssr"],"wrapper":{"profile":123,"version":456}}`),
},
},
},
wantErr: false,
},
Expand All @@ -330,11 +314,6 @@ func TestExtractPubmaticExtFromRequest(t *testing.T) {
},
expectedReqExt: extRequestAdServer{
Wrapper: &pubmaticWrapperExt{ProfileID: 123, VersionID: 456},
ExtRequest: openrtb_ext.ExtRequest{
Prebid: openrtb_ext.ExtRequestPrebid{
BidderParams: json.RawMessage(`{"acat":[1,3,4],"wrapper":{"profile":123,"version":456}}`),
},
},
},
wantErr: true,
},
Expand All @@ -348,12 +327,6 @@ func TestExtractPubmaticExtFromRequest(t *testing.T) {
expectedReqExt: extRequestAdServer{
Marketplace: &marketplaceReqExt{AllowedBidders: []string{"pubmatic", "groupm"}},
Wrapper: &pubmaticWrapperExt{ProfileID: 123, VersionID: 456},
ExtRequest: openrtb_ext.ExtRequest{
Prebid: openrtb_ext.ExtRequestPrebid{
BidderParams: json.RawMessage(`{"wrapper":{"profile":123,"version":456}}`),
AlternateBidderCodes: &openrtb_ext.ExtAlternateBidderCodes{Enabled: true, Bidders: map[string]openrtb_ext.ExtAdapterAlternateBidderCodes{"pubmatic": {Enabled: true, AllowedBidderCodes: []string{"groupm"}}}},
},
},
},
wantErr: false,
},
Expand Down
10 changes: 2 additions & 8 deletions adapters/pubmatic/pubmatictest/exemplary/banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"id": "1234"
}
}
},

},
"httpCalls": [
{
"expectedRequest": {
Expand Down Expand Up @@ -89,12 +88,7 @@
"profile": 5123,
"version":1
},
"acat": ["drg","dlu","ssr"],
"prebid": {
"bidderparams": {
"acat": ["drg","dlu","ssr"]
}
}
"acat": ["drg","dlu","ssr"]
}
},
"impIDs":["test-imp-id"]
Expand Down
2 changes: 1 addition & 1 deletion adapters/pubmatic/pubmatictest/exemplary/fledge.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
}
],
"ext": {"prebid":{}}
"ext": {}
},
"impIDs":["test-imp-id"]
},
Expand Down
3 changes: 1 addition & 2 deletions adapters/pubmatic/pubmatictest/exemplary/native.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
"wrapper": {
"profile": 5123,
"version": 1
},
"prebid": {}
}
}
},
"impIDs":["test-native-imp"]
Expand Down
8 changes: 1 addition & 7 deletions adapters/pubmatic/pubmatictest/exemplary/video.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
}
}
},

"httpCalls": [
{
"expectedRequest": {
Expand Down Expand Up @@ -100,12 +99,7 @@
"profile": 5123,
"version":1
},
"acat": ["drg","dlu","ssr"],
"prebid": {
"bidderparams": {
"acat": ["drg","dlu","ssr"]
}
}
"acat": ["drg","dlu","ssr"]
}
},
"impIDs":["test-video-imp"]
Expand Down
4 changes: 1 addition & 3 deletions adapters/pubmatic/pubmatictest/supplemental/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"ext":{}
}
},

"httpCalls": [
{
"expectedRequest": {
Expand Down Expand Up @@ -83,8 +82,7 @@
"wrapper": {
"profile": 5123,
"version":1
},
"prebid": {}
}
}
},
"impIDs":["app-imp"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@
"wrapper": {
"profile": 5123,
"version": 1
},
"prebid": {}
}
}
},
"impIDs":["test-imp-id"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@
"wrapper": {
"profile": 5123,
"version": 1
},
"prebid": {}
}
}
},
"impIDs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@
"wrapper": {
"profile": 5123,
"version": 1
},
"prebid": {}
}
}
},
"impIDs": [
Expand Down
17 changes: 0 additions & 17 deletions adapters/pubmatic/pubmatictest/supplemental/extra-bid.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
}
}
},

"httpCalls": [
{
"expectedRequest": {
Expand Down Expand Up @@ -103,22 +102,6 @@
"acat": ["drg","dlu","ssr"],
"marketplace": {
"allowedbidders": ["pubmatic", "groupm"]
},
"prebid": {
"bidderparams": {
"acat": ["drg","dlu","ssr"]
},
"alternatebiddercodes": {
"enabled": true,
"bidders": {
"pubmatic": {
"enabled": true,
"allowedbiddercodes": [
"groupm"
]
}
}
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@
"wrapper": {
"profile": 5123,
"version": 1
},
"prebid": {}
}
}
},
"impIDs":["test-imp-id"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@
"wrapper": {
"profile": 5123,
"version": 1
},
"prebid": {}
}
}
},
"impIDs":["test-imp-id"]
Expand Down
1 change: 0 additions & 1 deletion adapters/pubmatic/pubmatictest/supplemental/impExt.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
}
},
"ext": {
"prebid": {},
"wrapper": {
"profile": 5123,
"version": 1
Expand Down
Loading

0 comments on commit 993f157

Please sign in to comment.