Ok I got a working version that uses spellIds instead of spellNames. It works for debuffs and buffs BUT still shows both debuffs if they have an identical name (tested with druids Rake ability).
Also I am kinda convinced now, that your desired behaviour is actually not possible to achieve because the Blizzard function is only looking for spellNames and even if you filter two spells with the same name for their respective spellIds you would still have to handover the spellName in the end which is identical again (at least for my understanding of how the code operates).
Lua Code:
local whitelist = {
--[spellId] = {caster = unitId}
--[155722] = {caster = "player"}, --Rake Bleed
[163505] = {caster = "player"}, --Rake Stun
[155625] = {caster = "player"}, --Moonfire (Lunar Inspiration Talent)
[8936] = {caster = "player"} --Regrowth
}
local function newShouldShowBuff(_,name,caster)
for k, v in pairs(whitelist) do
local spellName, _, _, _, _, _, spellId = GetSpellInfo(k)
if spellName == name and spellId == k then
return name and caster and (whitelist[k].caster == caster or whitelist[k].caster == "all")
end
end
end
local function Mixin(baseFrame)
baseFrame.UnitFrame.BuffFrame.ShouldShowBuff = newShouldShowBuff
end
local f = CreateFrame("Frame")
f:RegisterEvent("NAME_PLATE_UNIT_ADDED")
f:SetScript("OnEvent", function(_,_,unitId)
Mixin(C_NamePlate.GetNamePlateForUnit(unitId))
end)
for _,baseFrame in pairs(C_NamePlate.GetNamePlates()) do
Mixin(baseFrame)
end