MCPcopy Create free account
hub / github.com/daodst/chat / GetPushRuleAttrByRuleID

Function GetPushRuleAttrByRuleID

clientapi/routing/pushrules.go:190–217  ·  view source on GitHub ↗
(ctx context.Context, scope, kind, ruleID, attr string, device *userapi.Device, userAPI userapi.ClientUserAPI)

Source from the content-addressed store, hash-verified

188}
189
190func GetPushRuleAttrByRuleID(ctx context.Context, scope, kind, ruleID, attr string, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
191 attrGet, err := pushRuleAttrGetter(attr)
192 if err != nil {
193 return errorResponse(ctx, err, "pushRuleAttrGetter failed")
194 }
195 ruleSets, err := queryPushRules(ctx, device.UserID, userAPI)
196 if err != nil {
197 return errorResponse(ctx, err, "queryPushRules failed")
198 }
199 ruleSet := pushRuleSetByScope(ruleSets, pushrules.Scope(scope))
200 if ruleSet == nil {
201 return errorResponse(ctx, jsonerror.InvalidArgumentValue("invalid push rule set"), "pushRuleSetByScope failed")
202 }
203 rulesPtr := pushRuleSetKindPointer(ruleSet, pushrules.Kind(kind))
204 if rulesPtr == nil {
205 return errorResponse(ctx, jsonerror.InvalidArgumentValue("invalid push rules kind"), "pushRuleSetKindPointer failed")
206 }
207 i := pushRuleIndexByID(*rulesPtr, ruleID)
208 if i < 0 {
209 return errorResponse(ctx, jsonerror.NotFound("push rule ID not found"), "pushRuleIndexByID failed")
210 }
211 return util.JSONResponse{
212 Code: http.StatusOK,
213 JSON: map[string]interface{}{
214 attr: attrGet((*rulesPtr)[i]),
215 },
216 }
217}
218
219func PutPushRuleAttrByRuleID(ctx context.Context, scope, kind, ruleID, attr string, body io.Reader, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
220 var newPartialRule pushrules.Rule

Callers 1

SetupFunction · 0.85

Calls 6

pushRuleAttrGetterFunction · 0.85
errorResponseFunction · 0.85
queryPushRulesFunction · 0.85
pushRuleSetByScopeFunction · 0.85
pushRuleSetKindPointerFunction · 0.85
pushRuleIndexByIDFunction · 0.85

Tested by

no test coverage detected