def _execute_flow(service_identity_user, message_flow_design, message_flow_run_record, members, message_parent_key, context=None, resultKey=None, force_language=None, broadcast_type=None, broadcast_guid=None, tag=None): logging.info("Executing message flow for %s with force_language %s" % (service_identity_user.email(), force_language)) xml_doc = _create_message_flow_run_xml_doc(service_identity_user, message_flow_design, message_flow_run_record, members, force_language) logging.info(xml_doc.toxml()) xml = xml_doc.toxml("utf-8") settings = get_server_settings() headers = { 'X-Nuntiuz-Service-Identifier-Key': get_mfr_sik(service_identity_user).sik, 'X-Nuntiuz-Service-Identity': base64.b64encode(get_identity_from_service_identity_user(service_identity_user)), 'X-Nuntiuz-Service-API-Key': get_mfr_api_key(service_identity_user).key().name(), 'X-Nuntiuz-Shared-Secret': settings.secret, 'X-Nuntiuz-MessageFlowRunId': message_flow_run_record.messageFlowRunId, 'X-Nuntiuz-MessageParentKey': message_parent_key if message_parent_key else "", 'X-Nuntiuz-Context': context if context else "", 'X-Nuntiuz-ResultKey': resultKey, 'Content-type': 'text/xml' } if broadcast_guid: headers['X-Nuntiuz-BroadcastGuid'] = broadcast_guid if tag: headers['X-Nuntiuz-Tag'] = tag.encode('utf') logging.debug('Executing flow with run id %s for members %s', message_flow_run_record.messageFlowRunId, members) result = urlfetch.fetch( "%s/api" % settings.messageFlowRunnerAddress, xml, "POST", headers, False, False, deadline=10 * 60) if result.status_code != 200: error_message = "MFR returned status code %d" % result.status_code if result.status_code == 400: logging.error(error_message, _suppress=False) raise deferred.PermanentTaskFailure(error_message) raise Exception(error_message) logging.debug('MFR response: %s', result.content) if len(members) == 1 and result.content: try: flow_start_result = parse_complex_value(FlowStartResultCallbackResultTO, json.loads(result.content), False) if isinstance(flow_start_result.value, MessageCallbackResultTypeTO): sendMessage(service_identity_user, [UserMemberTO(members[0], flow_start_result.value.alert_flags)], flow_start_result.value.flags, 0, message_parent_key, flow_start_result.value.message, flow_start_result.value.answers, None, flow_start_result.value.branding, flow_start_result.value.tag, flow_start_result.value.dismiss_button_ui_flags, context, key=resultKey, is_mfr=True, broadcast_type=broadcast_type, broadcast_guid=broadcast_guid, attachments=flow_start_result.value.attachments, step_id=None if flow_start_result.value.step_id is MISSING else flow_start_result.value.step_id) elif isinstance(flow_start_result.value, FormCallbackResultTypeTO): sendForm(service_identity_user, message_parent_key, members[0], flow_start_result.value.message, flow_start_result.value.form, flow_start_result.value.flags, flow_start_result.value.branding, flow_start_result.value.tag, flow_start_result.value.alert_flags, context, key=resultKey, is_mfr=True, broadcast_type=broadcast_type, attachments=flow_start_result.value.attachments, broadcast_guid=broadcast_guid, step_id=None if flow_start_result.value.step_id is MISSING else flow_start_result.value.step_id) except: logging.exception("Failed to parse result from message flow runner.")
def revoke_role(service_identity_user, user, role): admin = False service_identity = get_service_identity(service_identity_user) if not service_identity: raise ServiceIdentityDoesNotExistException(get_identity_from_service_identity_user(service_identity_user)) if isinstance(role, unicode): admin = True azzert(role in ROLES) # builtin else: azzert(role.service_user == service_identity.service_user) role = u'sr:%s' % role.role_id def trans(): user_profile = get_user_profile(user, False) user_profile.revoke_role(service_identity_user, role) user_profile.put() if admin: deferred.defer(drop_sessions_of_user, user, _transactional=True) if db.is_in_transaction(): trans() else: db.run_in_transaction(trans) if admin: _send_admin_role_updates(service_identity_user)
def grant_role(service_identity_user, user, role): admin = False service_identity = get_service_identity(service_identity_user) if not service_identity: raise ServiceIdentityDoesNotExistException(get_identity_from_service_identity_user(service_identity_user)) if isinstance(role, unicode): admin = True azzert(role in ROLES) # builtin else: azzert(role.service_user == service_identity.service_user) role = u'sr:%s' % role.role_id def trans(): user_profile = get_user_profile(user, False) bizz_check(user_profile, "User %s does not exist" % user.email()) user_profile.grant_role(service_identity_user, role) user_profile.put() if db.is_in_transaction(): trans() else: db.run_in_transaction(trans) if admin: _send_admin_role_updates(service_identity_user)
def bulk_create(description, tags, template_key=None, service_identity=None, flow=None, branding=None): from rogerthat.bizz.service import bulk_create_qr from rogerthat.bizz.service import get_and_validate_service_identity_user service_user = users.get_current_user() service_identity_user = get_and_validate_service_identity_user(service_user, service_identity) mfd_name = _get_and_validate_flow(service_user, flow) return bulk_create_qr(service_user, description, tags, template_key, get_identity_from_service_identity_user(service_identity_user), mfd_name, branding)
def update_beacons(service_identity_user, beacons): from rogerthat.bizz.service import BeaconAlreadyCoupledException, NoBeaconRegionFoundException if beacons is MISSING or beacons is None: beacons = list() service_user = get_service_user_from_service_identity_user(service_identity_user) identifier = get_identity_from_service_identity_user(service_identity_user) @db.non_transactional def _validate_beacon(beacon_name, beacon_uuid, beacon_major, beacon_minor, supported_app_ids): b = get_beacon(beacon_uuid, beacon_name) if b and b.service_identity_user != service_identity_user: raise BeaconAlreadyCoupledException(beacon_uuid, beacon_major, beacon_minor) for beacon_region in BeaconRegion.all().filter('uuid', beacon_uuid): if beacon_region.major is not None: if beacon_region.major != beacon_major: continue # the beacon does not belong to this region if beacon_region.minor is not None: if beacon_region.mino != beacon_minor: continue # the beacon does not belong to this region if beacon_region.app_id not in supported_app_ids: continue # the service_identity does not support this app break else: raise NoBeaconRegionFoundException(beacon_uuid, beacon_major, beacon_minor) def trans(): l = get_beacons(service_user, identifier) db.delete(l) beacons_to_put = list() for beacon in beacons: beacon_name = u"%s|%s" % (beacon.major, beacon.minor) beacon_uuid = beacon.uuid.lower() _validate_beacon(beacon_name, beacon_uuid, beacon.major, beacon.minor, get_service_identity(service_identity_user).appIds) b = Beacon(key=Beacon.create_key(service_identity_user, beacon_name)) b.uuid = beacon_uuid b.name = beacon_name b.tag = beacon.tag b.service_identity = identifier b.creation_time = now() beacons_to_put.append(b) if beacons_to_put: db.put(beacons_to_put) if db.is_in_transaction(): return trans() else: return db.run_in_transaction(trans)
def add_new_beacon(beacon_uuid, beacon_name, tag, service_identity_user): keyy = Beacon.create_key(service_identity_user, beacon_name) beacon = Beacon.get(keyy) if beacon: return False beacon = Beacon(key=keyy) beacon.uuid = beacon_uuid.lower() beacon.name = beacon_name beacon.tag = tag beacon.service_identity = get_identity_from_service_identity_user(service_identity_user) beacon.creation_time = now() beacon.put() return True
def handle_service_tracker_results(app_user, service_identity_user, location): slt = get_current_tracker(app_user, service_identity_user) if not slt: logging.info("Not sending location as the tracker has timed out or was disabled.") return if not slt.notified: # Calculate timezone based on users location deferred.defer(notify_location_tracking_enabled, location, service_identity_user, app_user, slt.key()) user_details = [UserDetailsTO.fromUserProfile(get_user_profile(app_user))] service_profile = get_service_profile(get_service_user_from_service_identity_user(service_identity_user)) location_fix(location_fix_response_receiver, logServiceError, service_profile, service_identity=get_identity_from_service_identity_user(service_identity_user), user_details=user_details, location=location, tracker_key=slt.encrypted_key())
def revoke_role(service_identity_user, user, role): admin = False service_identity = get_service_identity(service_identity_user) if not service_identity: raise ServiceIdentityDoesNotExistException(get_identity_from_service_identity_user(service_identity_user)) if isinstance(role, unicode): admin = True azzert(role in ROLES) # builtin role_str = role else: azzert(role.service_user == service_identity.service_user) role_str = u'%s' % role.role_id def trans(): new_look_and_feel = None new_look_and_feel_id = None look_n_feel_changed = False user_profile = get_user_profile(user, False) user_profile.revoke_role(service_identity_user, role_str) if not admin and user_profile.look_and_feel_id: look_and_feel = AppLookAndFeel.get_by_id(user_profile.look_and_feel_id) for role_mapping in look_and_feel.roles: # type: LookAndFeelServiceRoles if role.role_id in role_mapping.role_ids: new_look_and_feel = get_look_and_feel_for_user(user_profile, ignore_role=role.role_id) if new_look_and_feel: new_look_and_feel_id = new_look_and_feel.key.id() break if user_profile.look_and_feel_id: if not new_look_and_feel_id or user_profile.look_and_feel_id != new_look_and_feel_id: look_n_feel_changed = True user_profile.look_and_feel_id = new_look_and_feel_id user_profile.put() return new_look_and_feel, look_n_feel_changed new_look_n_feel, look_n_feel_changed = run_in_transaction(trans) if admin: deferred.defer(drop_sessions_of_user, user) _send_admin_role_updates(service_identity_user) if look_n_feel_changed: send_look_and_feel_update(user, new_look_n_feel)
def grant_roles(service_identity_user, user, roles): service_identity = get_service_identity(service_identity_user) if not service_identity: raise ServiceIdentityDoesNotExistException(get_identity_from_service_identity_user(service_identity_user)) admin = False role_ids = [] for role in roles: if isinstance(role, unicode): admin = True azzert(role in ROLES) # builtin role_ids.append(role) else: azzert(role.service_user == service_identity.service_user) role_ids.append(u'%s' % role.role_id) def trans(): look_and_feel = None user_profile = get_user_profile(user, False) bizz_check(user_profile, 'User %s does not exist' % user.email()) for role_id in role_ids: user_profile.grant_role(service_identity_user, role_id) if not user_profile.look_and_feel_id: look_n_feel = get_look_and_feel_for_user(user_profile) if look_n_feel: user_profile.look_and_feel_id = look_n_feel.id look_and_feel = look_n_feel user_profile.put() return look_and_feel look_n_feel = run_in_transaction(trans) if admin: _send_admin_role_updates(service_identity_user) if look_n_feel: send_look_and_feel_update(user, look_n_feel)
def post(self): from rogerthat.pages.shortner import get_short_url_by_code from rogerthat.service.api import friends as service_api_friends version = self.request.get("version", None) install_id = self.request.get("install_id", None) registration_time = self.request.get("registration_time", None) device_id = self.request.get("device_id", None) registration_id = self.request.get("registration_id", None) qr_url = self.request.get("qr_url", None) signature = self.request.get("signature", None) language = self.request.get("language", None) country = self.request.get("country", None) app_id = self.request.get("app_id", App.APP_ID_ROGERTHAT) use_xmpp_kick_channel = self.request.get('use_xmpp_kick', 'true') == 'true' GCM_registration_id = self.request.get('GCM_registration_id', '') if '-' in language: language = get_iso_lang(language.lower()) elif language and country: language = '%s_%s' % (language, country) server_settings = get_server_settings() calculated_signature = sha256_hex(version + " " + install_id + " " + registration_time + " " + device_id + " " + \ registration_id + " " + qr_url + base64.b64decode(server_settings.registrationMainSignature.encode("utf8"))) try: if signature.upper() != calculated_signature.upper(): logging.error("Invalid request signature.") self.response.set_status(500) return app = _verify_app_id(app_id) azzert(app is not None, "app_id is not found") bizz_check(install_id and qr_url, u"Could not validate QR code") installation = Installation.get_by_key_name(install_id) if not installation: platform = self.request.get("platform", None) if platform == "android": mobile_type = Mobile.TYPE_ANDROID_HTTP elif platform == "iphone": if use_xmpp_kick_channel: mobile_type = Mobile.TYPE_IPHONE_HTTP_XMPP_KICK else: mobile_type = Mobile.TYPE_IPHONE_HTTP_APNS_KICK elif platform == "windows_phone": mobile_type = Mobile.TYPE_WINDOWS_PHONE else: logging.error("Unknown platform: %s" % platform) self.response.set_status(500) return now_ = now() installation = Installation(key_name=install_id, version=version, platform=mobile_type, timestamp=now_, app_id=app_id) installation_log = InstallationLog(parent=installation, timestamp=now_, description="Installed with language %s" % language) installation_log_app_id = InstallationLog(parent=installation, timestamp=now_, description="Installed with app_id: %s" % app_id) put_and_invalidate_cache(installation, installation_log, installation_log_app_id) InstallationLog(parent=installation, timestamp=now(), description="Creating qr based profile & validating registration request. Language: %s, QR url: %s" % (language, qr_url)).put() m = re.match('(.*)/(M|S)/(.*)', qr_url) bizz_check(m, u"Could not validate QR code") entry_point = m.group(2) code = m.group(3) bizz_check(entry_point == "S", u"Could not validate QR code") su = get_short_url_by_code(code) bizz_check(su, u"Could not validate QR code") logging.debug("register_via_qr qr_url: %s", qr_url) logging.debug("register_via_qr su.full: %s", su.full) match = re.match("^/q/s/(.+)/(\\d+)$", su.full) bizz_check(match, u"Could not validate QR code") user_code = match.group(1) service_profile = get_service_profile_via_user_code(user_code) bizz_check(service_profile, u"Could not validate QR code") service_user = service_profile.user sid = int(match.group(2)) service_interaction_def = get_service_interaction_def(service_user, int(sid)) service_identity_user = create_service_identity_user(service_user, service_interaction_def.service_identity) service_identity = get_identity_from_service_identity_user(service_identity_user) svc_profile = get_service_profile(service_user) logging.debug("register_via_qr service_identity_user: %s", service_identity_user) human_user = users.User(u"*****@*****.**" % uuid.uuid4().get_hex()) app_user = create_app_user(human_user, app_id) from rogerthat.bizz.profile import _create_new_avatar avatar, _ = _create_new_avatar(app_user, add_trial_overlay=False) user_profile = UserProfile(parent=parent_key(app_user), key_name=app_user.email()) user_profile.name = None user_profile.language = language user_profile.avatarId = avatar.key().id() user_profile.app_id = get_app_id_from_app_user(app_user) user_details = [UserDetailsTO.fromUserProfile(user_profile)] r = service_api_friends.register(None, None, svc_profile, service_identity=service_identity, user_details=user_details, origin=REGISTRATION_ORIGIN_QR, PERFORM_CALLBACK_SYNCHRONOUS=True) logging.debug("register_via_qr with id: %s", r) bizz_check(r == ACCEPT_ID or r == ACCEPT_AND_CONNECT_ID, u"Service denied your install") installation.service_identity_user = service_identity_user installation.service_callback_result = r installation.qr_url = su.full[4:] installation.put() # Create registration entry. self.response.headers['Content-Type'] = 'text/json' registration = Registration(parent=parent_key(app_user), key_name=registration_id) registration.timestamp = int(registration_time) registration.device_id = device_id registration.pin = -1 registration.timesleft = -1 registration.installation = installation registration.language = language registration.put() account, registration.mobile, age_and_gender_set = register_mobile(human_user, app_id=app_id, use_xmpp_kick_channel=use_xmpp_kick_channel, GCM_registration_id=GCM_registration_id, language=registration.language) installation_log = InstallationLog(parent=installation, timestamp=now(), profile=get_user_profile(app_user), \ description="Profile created & registration request validated.", \ registration=registration, mobile=registration.mobile) db.put([registration, installation_log]) self.response.out.write(json.dumps(dict(account=account.to_dict(), email=human_user.email(), age_and_gender_set=age_and_gender_set))) except BusinessException, be: logging.debug("BusinessException during via QR handler %s", be) self.response.set_status(500) return
def finish_registration(mobile_account, mobileInfo, accounts, invitor_code, invitor_secret, ipaddress): from rogerthat.service.api import friends as service_api_friends m = get_mobile_by_account(mobile_account) mobile_key = m.key() ms_key = MobileSettings.get(m).key() profile_key = get_user_profile_key(m.user) def trans(): mobile, ms, my_profile = db.get((mobile_key, ms_key, profile_key)) mobile.status = mobile.status | Mobile.STATUS_REGISTERED mobile.type = mobileInfo.app_type mobile.simCountry = mobileInfo.sim_country if mobileInfo.sim_country != MISSING else None mobile.simCountryCode = mobileInfo.sim_country_code if mobileInfo.sim_country_code != MISSING else None mobile.simCarrierCode = mobileInfo.sim_carrier_code if mobileInfo.sim_carrier_code != MISSING else None mobile.simCarrierName = mobileInfo.sim_carrier_name if mobileInfo.sim_carrier_name != MISSING else None mobile.netCountry = mobileInfo.net_country if mobileInfo.net_country != MISSING else None mobile.netCountryCode = mobileInfo.net_country_code if mobileInfo.net_country_code != MISSING else None mobile.netCarrierCode = mobileInfo.net_carrier_code if mobileInfo.net_carrier_code != MISSING else None mobile.netCarrierName = mobileInfo.net_carrier_name if mobileInfo.net_carrier_name != MISSING else None mobile.hardwareModel = mobileInfo.device_model_name mobile.osVersion = mobileInfo.device_os_version if mobileInfo.device_os_version != MISSING else None mobile.localeLanguage = mobileInfo.locale_language if mobileInfo.locale_language and mobileInfo.locale_language != MISSING else DEFAULT_LANGUAGE mobile.localeCountry = mobileInfo.locale_country mobile.timezone = mobileInfo.timezone if mobileInfo.timezone != MISSING else None mobile.timezoneDeltaGMT = mobileInfo.timezone_delta_gmt if mobileInfo.timezone_delta_gmt != MISSING else None if mobileInfo.app_major_version != MISSING and mobileInfo.app_minor_version != MISSING: ms.majorVersion = mobileInfo.app_major_version ms.minorVersion = mobileInfo.app_minor_version # This is the official place where we set the profile language my_profile.language = mobile.localeLanguage my_profile.country = mobile.netCountry or mobile.simCountry or mobile.localeCountry my_profile.timezone = mobile.timezone my_profile.timezoneDeltaGMT = mobile.timezoneDeltaGMT my_profile.mobiles = MobileDetails() my_profile.mobiles.addNew(mobile.account, mobile.type, mobile.pushId, mobile.app_id) mobile.put() ms.put() my_profile.put() deferred.defer(_finishup_mobile_registration, mobile, accounts, invitor_code, invitor_secret, ipaddress, ms_key, _transactional=True) return mobile, my_profile xg_on = db.create_transaction_options(xg=True) mobile, my_profile = db.run_in_transaction_options(xg_on, trans) channel.send_message(mobile.user, u'com.mobicage.registration.finished') typestr = "Unknown type" try: typestr = Mobile.typeAsString(mobile.type) except ValueError: pass server_settings = get_server_settings() registration = get_registration_by_mobile(mobile) if registration: InstallationLog(parent=registration.installation, timestamp=now(), registration=registration, mobile=mobile, profile=my_profile, description="Registration successful.").put() if registration.installation and registration.installation.qr_url: service_user = get_service_user_from_service_identity_user(registration.installation.service_identity_user) service_identity = get_identity_from_service_identity_user(registration.installation.service_identity_user) svc_profile = get_service_profile(service_user) user_details = [UserDetailsTO.fromUserProfile(my_profile)] if registration.installation.service_callback_result == ACCEPT_AND_CONNECT_ID: service_identity_user = create_service_identity_user(service_user, service_identity) si = get_service_identity(service_identity_user) bizz_check(si, "ServiceIdentity %s not found" % service_identity_user) xmpp.send_message(server_settings.xmppInfoMembers, "User %s registered %s (%s) with account:\n%s\nFor service %s %s" % ( mobile.user, mobile.hardwareModel, typestr, mobile.account, si.name, service_identity_user), message_type=xmpp.MESSAGE_TYPE_CHAT) app_id = get_app_id_from_app_user(mobile.user) if app_id not in si.appIds: si.appIds.append(app_id) put_and_invalidate_cache(si) try_or_defer(makeFriends, mobile.user, service_identity_user, original_invitee=None, servicetag=None, origin=None, notify_invitee=False, notify_invitor=False, user_data=None) else: xmpp.send_message(server_settings.xmppInfoMembers, "User %s registered %s (%s) with account:\n%s" % ( mobile.user, mobile.hardwareModel, typestr, mobile.account), message_type=xmpp.MESSAGE_TYPE_CHAT) service_api_friends.register_result(register_result_response_receiver, logServiceError, svc_profile, service_identity=service_identity, user_details=user_details, origin=REGISTRATION_ORIGIN_QR) else: xmpp.send_message(server_settings.xmppInfoMembers, "User %s registered %s (%s) with account:\n%s" % ( mobile.user, mobile.hardwareModel, typestr, mobile.account), message_type=xmpp.MESSAGE_TYPE_CHAT) app = get_app_by_id(get_app_id_from_app_user(mobile.user)) if app.admin_services: service_profiles = filter(None, db.get((get_profile_key(users.User(e)) for e in app.admin_services))) if service_profiles: user_details = [UserDetailsTO.fromUserProfile(my_profile)] for service_profile in service_profiles: service_api_friends.register_result(register_result_response_receiver, logServiceError, service_profile, service_identity=ServiceIdentity.DEFAULT, user_details=user_details, origin=REGISTRATION_ORIGIN_DEFAULT) else: xmpp.send_message(server_settings.xmppInfoMembers, "User %s registered %s (%s) with account:\n%s\nBut registration model was not found!" % ( mobile.user, mobile.hardwareModel, typestr, mobile.account), message_type=xmpp.MESSAGE_TYPE_CHAT) return mobile
def fromServiceIdentity(service_identity, service_profile): identifier = get_identity_from_service_identity_user(service_identity.user) if identifier == ServiceIdentity.DEFAULT: azzert(service_identity.inheritanceFlags == 0, "inheritanceFlags of default must be 0, not %s" % service_identity.inheritanceFlags) details = ServiceIdentitySummaryTO.fromServiceIdentity(service_identity, ServiceIdentityDetailsTO()) details.description_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_DESCRIPTION, service_identity.inheritanceFlags) details.description = service_identity.description details.description_branding_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_DESCRIPTION_BRANDING, service_identity.inheritanceFlags) details.description_branding = service_identity.descriptionBranding details.menu_branding_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_MENU_BRANDING, service_identity.inheritanceFlags) details.phone_number_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_PHONE_NUMBER, service_identity.inheritanceFlags) details.phone_number = service_identity.mainPhoneNumber details.phone_call_popup_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_PHONE_POPUP_TEXT, service_identity.inheritanceFlags) details.phone_call_popup = service_identity.callMenuItemConfirmation details.recommend_enabled = bool(service_identity.shareEnabled) details.admin_emails = [] if service_identity.metaData is None else [e.strip() for e in service_identity.metaData.split(',') if e.strip()] if service_identity.serviceData: service_data = service_identity.serviceData.to_json_dict() details.app_data = json.dumps(service_data).decode('utf-8') if service_data else None else: details.app_data = service_identity.appData details.search_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_SEARCH_CONFIG, service_identity.inheritanceFlags) sc, locs = get_search_config(service_identity.user) details.search_config = SearchConfigTO.fromDBSearchConfig(sc, locs) details.qualified_identifier = service_identity.qualifiedIdentifier details.email_statistics_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_EMAIL_STATISTICS, service_identity.inheritanceFlags) details.email_statistics = service_identity.emailStatistics details.app_ids_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_APP_IDS, service_identity.inheritanceFlags) details.app_ids = [] details.app_names = [] for app in get_apps_by_id(service_identity.sorted_app_ids): details.app_ids.append(app.app_id) details.app_names.append(app.name) details.can_edit_supported_apps = service_profile.canEditSupportedApps details.content_branding_hash = service_identity.contentBrandingHash details.home_branding_use_default = is_flag_set(ServiceIdentity.FLAG_INHERIT_HOME_BRANDING, service_identity.inheritanceFlags) details.home_branding_hash = service_identity.homeBrandingHash return details
def service_identity(self): return get_identity_from_service_identity_user( self.service_identity_user)
def disable_news_with_coupon(coupon_id, service_identity_user, member): coupon = NewsCoupon.get( NewsCoupon.create_key(coupon_id, service_identity_user)) news.disable_news( coupon.news_id, [member], get_identity_from_service_identity_user(service_identity_user))