Skip to content

Commit

Permalink
fix mgmt api error when creating topic with subscribers (#138)
Browse files Browse the repository at this point in the history
CPCN-355
  • Loading branch information
petrjasek authored Oct 25, 2023
1 parent 3a40c88 commit 1a70b4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 0 additions & 3 deletions server/cp/mgmt_api/topics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import superdesk

from bson import ObjectId
from flask import current_app as app

from newsroom.topics.topics import TopicsResource, TopicsService
Expand Down Expand Up @@ -30,8 +29,6 @@ def on_create(self, docs):
elif not doc.get('is_global'):
message = ("Please set is_global True, or provide user in the body.")
raise SuperdeskApiError.badRequestError(message=message, payload=message)
if doc.get('subscribers'):
doc['subscribers'] = [ObjectId(sub) for sub in doc['subscribers']]

def on_created(self, docs):
super().on_created(docs)
Expand Down
10 changes: 8 additions & 2 deletions server/features/mgmt_api_topics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ Feature: Management API - Topics
"topic_type": "wire",
"query": "topic1",
"is_global": true,
"user": "#users._id#"
"user": "#users._id#",
"subscribers": [
{"user_id": "#users._id#"}
]
}
"""
Then we get response code 201
Expand All @@ -43,7 +46,10 @@ Feature: Management API - Topics
"topic_type": "wire",
"query": "topic1",
"is_global": true,
"user": "#users._id#"
"user": "#users._id#",
"subscribers": [
{"user_id": "#users._id#", "notification_type": "real-time"}
]
}
]
}
Expand Down

0 comments on commit 1a70b4f

Please sign in to comment.